Skip to content

raise without from discards exception chain in 12 remaining sites #2564

@blackwell-systems

Description

@blackwell-systems

Initial Checks

Description

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions