modelcontextprotocol / modelcontextprotocol/python-sdk
raise without from discards exception chain in 12 remaining sites
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 24.3k
- Fork
- 4k
- Merge medio
- 1g 1h
- PR unite (30g)
- 31
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia ispezionando i 12 punti elencati in client/session.py, client/auth/utils.py, server/auth/middleware/client_auth.py, server/mcpserver/resources/types.py, resource_manager.py, templates.py e prompts/base.py. Confrontali con gli usi esistenti in server.py, func_metadata.py e tools/base.py. Il lavoro è completato quando ogni eccezione rilanciata conserva l’originale come causa diretta e il comportamento rilevante del client e del server continua a superare i test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 74/100