modelcontextprotocol / modelcontextprotocol/python-sdk

raise without from discards exception chain in 12 remaining sites

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

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

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

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.

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 kiểm tra 12 vị trí được liệt kê trong client/session.py, client/auth/utils.py, server/auth/middleware/client_auth.py, server/mcpserver/resources/types.py, resource_manager.py, templates.py và prompts/base.py. So sánh chúng với các cách sử dụng hiện có trong server.py, func_metadata.py và tools/base.py. Hoàn thành khi mỗi ngoại lệ được ném lại đều giữ ngoại lệ ban đầu làm nguyên nhân trực tiếp của nó và hành vi liên quan của client và server vẫn vượt qua các kiểm thử.

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ó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
74/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.