modelcontextprotocol / modelcontextprotocol/python-sdk
raise without from discards exception chain in 12 remaining sites
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 24.3k
- Forks
- 4k
- Ø Merge
- 1 T. 1 Std.
- Gemergte PRs (30 T.)
- 31
Beschreibung
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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Untersuchung der 12 aufgeführten Stellen in client/session.py, client/auth/utils.py, server/auth/middleware/client_auth.py, server/mcpserver/resources/types.py, resource_manager.py, templates.py und prompts/base.py. Vergleiche sie mit den bestehenden Verwendungen in server.py, func_metadata.py und tools/base.py. Als abgeschlossen gilt die Aufgabe, wenn jede erneut ausgelöste Ausnahme das Original als ihre unmittelbare Ursache bewahrt und das relevante Client- und Serververhalten weiterhin erfolgreich ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- backend
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 74/100