modelcontextprotocol / modelcontextprotocol/python-sdk

ExceptionGroup wrapping obscures real errors from task groups

Đang mở
#2,114 3 bình luận 2 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug P1 v2
Ngôn ngữ chính
Python
Star
24.3k
Fork
4k
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
31

Mô tả

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 BaseExceptionGroup containing the real error plus multiple Cancelled exceptions
  • 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)

AI Disclaimer

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu bằng cách đọc phần xử lý nhóm tác vụ trong src/mcp/shared/session.py và src/mcp/client/streamable_http.py, sau đó kiểm tra các vị trí create_task_group() khác được đề cập trong issue. Tái hiện lỗi kết nối với các tác vụ anh em bị hủy và xác minh rằng ngoại lệ thực sự được truyền qua các vị trí gọi bị ảnh hưởng mà không có nhiễu do việc hủy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
backend
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.