modelcontextprotocol / modelcontextprotocol/python-sdk
raise without from discards exception chain in 12 remaining sites
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 24.3k
- 派生
- 4k
- 平均合并
- 1 天 1 小时
- 30 天内合并 PR
- 31
描述
Initial Checks
- I confirm that I'm using the latest version of MCP Python SDK
- I confirm that I searched for my issue in https://github.com/modelcontextprotocol/python-sdk/issues before opening this issue
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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先检查 client/session.py、client/auth/utils.py、server/auth/middleware/client_auth.py、server/mcpserver/resources/types.py、resource_manager.py、templates.py 和 prompts/base.py 中列出的 12 处。将它们与 server.py、func_metadata.py 和 tools/base.py 中现有的用法进行比较。当每个重新抛出的异常都将原始异常保留为其直接原因,并且相关的客户端和服务器行为仍然通过时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 冷清
- 描述清晰度
- 描述清楚
- 新手友好度
- 74/100