modelcontextprotocol / modelcontextprotocol/python-sdk
ExceptionGroup wrapping obscures real errors from task groups
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 24.3k
- Forks
- 4k
- Merge médio
- 1d 1h
- PRs com merge (30d)
- 31
Descrição
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)
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Comece lendo o tratamento de grupos de tarefas em src/mcp/shared/session.py e src/mcp/client/streamable_http.py; depois, inspecione os outros locais de create_task_group() mencionados na issue. Reproduza uma falha de conexão com tarefas irmãs canceladas e verifique se a exceção real se propaga sem ruído de cancelamento pelos pontos de chamada afetados.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- backend
- Tipo de issue
- Bug
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Status de atividade
- Pouca atividade
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 48/100