raise without from discards exception chain in 12 remaining sites

Aperta
#2,564 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
74/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
python
Ambito
backend

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.

Descrizione

bug P3
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.

Lingua principale
Python
Stelle
24.3k
Fork
4k
Merge medio
1g 1h
PR unite (30g)
31

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di modelcontextprotocol/python-sdk

Tutte le issue di modelcontextprotocol/python-sdk

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.