modelcontextprotocol / modelcontextprotocol/python-sdk
ExceptionGroup wrapping obscures real errors from task groups
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 24.3k
- Forks
- 4k
- Merge medio
- 1 d 1 h
- PR fusionados (30 d)
- 31
Descripción
Summary
When SDK internal anyio task group tasks fail, the real error is wrapped in a BaseExceptionGroup alongside Cancelled exceptions from cancelled sibling tasks. This makes error classification extremely difficult for callers — they cannot reliably determine the root cause of a failure.
There are 16 create_task_group() usages across the SDK with no except* syntax or ExceptionGroup unwrapping anywhere.
Expected Behavior
- Callers should receive the original exception, not an ExceptionGroup wrapping it alongside cancellation noise
- When a task group has one real failure and N cancelled siblings, only the real failure should propagate
Current Behavior
- A single connection failure produces a
BaseExceptionGroupcontaining the real error plus multipleCancelledexceptions - Callers must manually unwrap exception groups to find the root cause
- This affects ~80+ call sites across the SDK where task groups are used
Affected Code
src/mcp/shared/session.py(session task groups)src/mcp/client/streamable_http.py(transport task groups)- All other
create_task_group()sites
Related
- #1742 — broader typed error classes design
- #1830 — CancelledError indistinguishable from external cancellation (closed but related)
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Empieza leyendo la gestión de grupos de tareas en src/mcp/shared/session.py y src/mcp/client/streamable_http.py; después, inspecciona los otros sitios de create_task_group() mencionados en el issue. Reproduce un fallo de conexión con tareas hermanas canceladas y verifica que la excepción real se propaga sin ruido de cancelación en los puntos de llamada afectados.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- backend
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100