modelcontextprotocol / modelcontextprotocol/python-sdk
ExceptionGroup wrapping obscures real errors from task groups
オープン
まだ誰も着手していません。
bug
P1
v2
- 主要言語
- Python
- スター
- 24.3k
- フォーク
- 4k
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 31
説明
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)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず src/mcp/shared/session.py と src/mcp/client/streamable_http.py のタスクグループ処理を読み、次に issue で言及されている create_task_group() の他の箇所を調べます。キャンセルされた兄弟タスクを伴う接続失敗を再現し、実際の例外がキャンセル由来のノイズなしに影響を受ける呼び出し箇所へ伝播することを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100