You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
raise without from discards exception chain in 12 remaining sites #2564
Follow-up to #2541 (fixed in #2542). The same pattern exists in 12 additional sites across 7 files. Each catches an exception and re-raises a new one without from, discarding the original traceback and __cause__.
Sites:
File
Line
Caught
Raised
client/session.py
346
ValidationError
RuntimeError
client/session.py
348
SchemaError
RuntimeError
client/auth/utils.py
246
ValidationError
OAuthRegistrationError
client/auth/utils.py
339
ValidationError
OAuthTokenError
server/auth/middleware/client_auth.py
83
ValueError/UnicodeDecodeError/binascii.Error
AuthenticationError
server/mcpserver/resources/types.py
75
Exception
ValueError
server/mcpserver/resources/types.py
151
Exception
ValueError
server/mcpserver/resources/types.py
196
Exception
ValueError
server/mcpserver/resources/types.py
205
Exception
ValueError
server/mcpserver/resources/resource_manager.py
96
Exception
ValueError
server/mcpserver/resources/templates.py
133
Exception
ValueError
server/mcpserver/prompts/base.py
185, 189
Exception
ValueError
Impact
Same as #2541: without from, Python shows "During handling of the above exception, another exception occurred" instead of "The above exception was the direct cause of the following exception." Callers cannot inspect __cause__ to determine the root cause programmatically.
The codebase already uses from correctly in server.py:451, server.py:459, server.py:1112, func_metadata.py:216,265, and tools/base.py:119. These 12 sites are the remaining inconsistencies.
The line numbers in the table have moved since July, so I re-derived the list from main with an AST pass rather than trusting them: 12 sites still raise a new exception inside an except without from. Eleven of them are the pattern this issue is about. The twelfth is shared/_context_streams.py:91, raise StopAsyncIteration inside an except that is ending an iterator, where a from would attach a cause to ordinary control flow rather than preserve a lost one, so I plan to leave that one alone and say so in the PR instead of quietly counting it as fixed.
I run this SDK inside my own tool, which is how I ended up here. Will open a PR with the suite run against it.
Disclosure: prepared with an AI coding assistant; the PR will say the same.
Withdrawing that: #2565 has been open on this since May and does the same work, which I should have checked before saying anything. Apologies for the noise.
For whoever picks this up later, the state as of today: that PR touches seven files and now conflicts with main, and the sites have moved since it was written. An AST pass over current main finds twelve raise statements inside an except with no from, eleven of which are this issue's pattern; the twelfth is shared/_context_streams.py:91, raise StopAsyncIteration ending an iterator, where a cause would attach to ordinary control flow rather than preserve a lost one.
Opened a fix in #3312 covering the remaining 11 sites across 6 files. A few sites from the original list (resource_manager.py, templates.py, resolve.py) were already fixed on current main, so the PR addresses only the ones still missing from.
Activity
fix: chain exceptions with 'from' in missed raise sites
overgoy commentedon Aug 15, 2026
Taking this one, if nobody else is on it.
The line numbers in the table have moved since July, so I re-derived the list from
mainwith an AST pass rather than trusting them: 12 sites still raise a new exception inside anexceptwithoutfrom. Eleven of them are the pattern this issue is about. The twelfth isshared/_context_streams.py:91,raise StopAsyncIterationinside anexceptthat is ending an iterator, where afromwould attach a cause to ordinary control flow rather than preserve a lost one, so I plan to leave that one alone and say so in the PR instead of quietly counting it as fixed.I run this SDK inside my own tool, which is how I ended up here. Will open a PR with the suite run against it.
Disclosure: prepared with an AI coding assistant; the PR will say the same.
overgoy commentedon Aug 15, 2026
Withdrawing that: #2565 has been open on this since May and does the same work, which I should have checked before saying anything. Apologies for the noise.
For whoever picks this up later, the state as of today: that PR touches seven files and now conflicts with main, and the sites have moved since it was written. An AST pass over current main finds twelve
raisestatements inside anexceptwith nofrom, eleven of which are this issue's pattern; the twelfth isshared/_context_streams.py:91,raise StopAsyncIterationending an iterator, where a cause would attach to ordinary control flow rather than preserve a lost one.Disclosure: prepared with an AI coding assistant.
syahra712 commentedon Aug 15, 2026
Opened a fix in #3312 covering the remaining 11 sites across 6 files. A few sites from the original list (resource_manager.py, templates.py, resolve.py) were already fixed on current
main, so the PR addresses only the ones still missingfrom.