Skip to content

fix: chain exceptions with from in 12 remaining raise sites#2565

Open
blackwell-systems wants to merge 1 commit intomodelcontextprotocol:mainfrom
blackwell-systems:fix/chain-remaining-exceptions
Open

fix: chain exceptions with from in 12 remaining raise sites#2565
blackwell-systems wants to merge 1 commit intomodelcontextprotocol:mainfrom
blackwell-systems:fix/chain-remaining-exceptions

Conversation

@blackwell-systems
Copy link
Copy Markdown
Contributor

Summary

Follow-up to #2542. Adds from to 12 remaining raise statements inside except blocks that discard the original exception chain.

Fixes #2564

Changes

7 files, 12 sites. Each change adds from e (or from exc) to an existing raise inside an except block:

  • client/session.py: ValidationError, SchemaError re-raised as RuntimeError
  • client/auth/utils.py: ValidationError re-raised as OAuthRegistrationError, OAuthTokenError
  • server/auth/middleware/client_auth.py: ValueError/UnicodeDecodeError/binascii.Error re-raised as AuthenticationError
  • server/mcpserver/resources/types.py: 4 sites in FunctionResource, FileResource, DirectoryResource
  • server/mcpserver/resources/resource_manager.py: 1 site
  • server/mcpserver/resources/templates.py: 1 site
  • server/mcpserver/prompts/base.py: 2 sites (also adds as e binding on line 184 which was missing)

How Has This Been Tested?

All changes are purely additive (from clause) and do not alter control flow or exception types. Existing tests pass unchanged:

1172 passed, 98 skipped, 0 failures

Ruff and pyright pass with zero errors on all changed files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

raise without from discards exception chain in 12 remaining sites

1 participant