modelcontextprotocol / modelcontextprotocol/python-sdk
raise without from discards exception chain in 12 remaining sites
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 24.3k
- Forks
- 4k
- Merge moyen
- 1 j 1 h
- PR mergées (30 j)
- 31
Description
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
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.
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par inspecter les 12 emplacements indiqués dans client/session.py, client/auth/utils.py, server/auth/middleware/client_auth.py, server/mcpserver/resources/types.py, resource_manager.py, templates.py et prompts/base.py. Comparez-les avec les utilisations existantes dans server.py, func_metadata.py et tools/base.py. Le travail est terminé lorsque chaque exception relancée conserve l’exception d’origine comme cause directe et que le comportement pertinent du client et du serveur continue de passer.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- backend
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- Calme
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 74/100