-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix: improve misleading warning for progress callback exceptions #775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
felixweinberger
merged 15 commits into
modelcontextprotocol:main
from
lorenzocesconetto:lorenzocesconetto/fix-callback-exception-warning
Sep 30, 2025
+79
−5
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e6760af
fix: improve misleading warning for progress callback exceptions
lorenzocesconetto be40a3e
fix: small typo
lorenzocesconetto f1a964c
Add unit test + remove try-except-else + add try-except for JSONRPCRe…
lorenzocesconetto 2544c9c
Swap generic Exception for ValidationError
lorenzocesconetto 8d646e5
Merge branch 'main' into lorenzocesconetto/fix-callback-exception-war…
lorenzocesconetto 22cd2db
Elevate callback exception log to error
lorenzocesconetto e973737
Fix unit tests
lorenzocesconetto 5e1b3bb
Merge branch 'main' into lorenzocesconetto/fix-callback-exception-war…
lorenzocesconetto 0512742
Merge remote-tracking branch 'upstream/main' into lorenzocesconetto/f…
lorenzocesconetto c3fc092
fix: test + formatting
lorenzocesconetto 52cff03
fix: unused import
lorenzocesconetto d6cd675
fix: type hints
lorenzocesconetto 3e84e24
Merge branch 'main' into lorenzocesconetto/fix-callback-exception-war…
felixweinberger ab2ce91
Merge branch 'main' into lorenzocesconetto/fix-callback-exception-war…
felixweinberger 0938ea0
Merge branch 'main' into lorenzocesconetto/fix-callback-exception-war…
felixweinberger File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -392,11 +392,17 @@ async def _receive_loop(self) -> None: | |
# call it with the progress information | ||
if progress_token in self._progress_callbacks: | ||
callback = self._progress_callbacks[progress_token] | ||
await callback( | ||
notification.root.params.progress, | ||
notification.root.params.total, | ||
notification.root.params.message, | ||
) | ||
try: | ||
await callback( | ||
notification.root.params.progress, | ||
notification.root.params.total, | ||
notification.root.params.message, | ||
) | ||
except Exception as e: | ||
logging.error( | ||
"Progress callback raised an exception: %s", | ||
e, | ||
) | ||
Comment on lines
+402
to
+405
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
await self._received_notification(notification) | ||
await self._handle_incoming(notification) | ||
except Exception as e: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an outer exception block 🤔
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair - how would you propose addressing the misleading part here instead? The callback could be anything, so it could throw any kind of exception.
We could potentially replace 410 to just be a generic
logging.exception(e)
without any additional decoration? In order to be more broad without adding misleading commentary?