fix: improve misleading warning for progress callback exceptions
Currently if the progress notification callback throws an exception we get a misleading warning message. This PR aims to fix it.
Motivation and Context
How Has This Been Tested?
Ran a few tests locally.
Breaking Changes
No breaking changes.
Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation update
Checklist
- [x] I have read the MCP Documentation
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [x] I have added appropriate error handling
- [x] I have added or updated documentation as needed
Additional context
Hi @ihrpr thank you for the review. I'll add the tests.
Hi @ihrpr, ready for another pass! I've added the unit test and removed the try-except-else as you've requested.
Why is it misleading? Do you have a MRE that I can check this locally?
Also, if this makes sense, we should except on ValidationError, not on Exception.
Thank you for your reviews and comments @Kludex and @ihrpr!
Totally agree with you guys and changed to ValidationError in the try-except.
I only kept the generic Exception around the callback execution since we don't know what kind of exception might be raised in there.
@Kludex the "misleading" part is that it prints Failed to validate notification... when the user's callback raises an exception. When I saw that for the first time I thought the server notification message was not following the protocol's standard (or the client validation was broken). That message is very misleading. The root cause was a bad implementation of the callback.
@ihrpr can you take another look?
Hi @felixweinberger, thanks for getting back to me, I'll update this PR. I am actually interested in contributing more to this repo as long as core contributors are willing to provide quick feedback. Lmk if there's any other issues across the repo that could use an extra pair of hands.
Hi @felixweinberger, thanks for getting back to me, I'll update this PR. I am actually interested in contributing more to this repo as long as core contributors are willing to provide quick feedback. Lmk if there's any other issues across the repo that could use an extra pair of hands.
Thank you for the feedback and yes it's something we're currently working on the team to improve coverage for (so we can get back to people more quickly). I'll be sure to get back to you quickly on this PR.
Thank you for the offer of making more contributions! I'm currently trying to get a handle on clusters of issues on the python SDK worth prioritizing, I'll let you know if I find something suitable that needs some help!
@felixweinberger pulled the latest changes and resolved the conflicts.
But it seems that one of the tests is breaking for python 3.10 but runs successfully for other versions, interesting...
@felixweinberger pulled the latest changes and resolved the conflicts. But it seems that one of the tests is breaking for python
3.10but runs successfully for other versions, interesting...
Thanks! There is occasional flakiness in the tests, I restarted it let's see if it was one of those.
@felixweinberger thanks for moving forward with this.