Title: fix: chain exceptions in get_prompt and read_resource handlers by blackwell-systems · Pull Request #2542 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: fix: chain exceptions in get_prompt and read_resource handlers by blackwell-systems · Pull Request #2542 · modelcontextprotocol/python-sdk
X Title: fix: chain exceptions in get_prompt and read_resource handlers by blackwell-systems · Pull Request #2542 · modelcontextprotocol/python-sdk
Description: Summary Two raise statements in server/mcpserver/server.py discard the causal exception chain: Line 1112: raise ValueError(str(e)) → raise ValueError(str(e)) from e Line 451: raise ResourceError(...) → raise ResourceError(...) from exc Motivation and Context The same file uses from exc correctly at line 459. These two sites are inconsistent and lose the original traceback, making it impossible for callers to programmatically inspect the root cause via __cause__. Without from, Python shows "During handling of the above exception, another exception occurred" which is confusing. With from, it shows "The above exception was the direct cause of the following exception" and preserves the chain for isinstance() checks on __cause__. How Has This Been Tested? The change is purely additive (adds from clause) and does not alter control flow or exception types. Existing tests pass unchanged. Fixes #2541
Open Graph Description: Summary Two raise statements in server/mcpserver/server.py discard the causal exception chain: Line 1112: raise ValueError(str(e)) → raise ValueError(str(e)) from e Line 451: raise ResourceError(....
X Description: Summary Two raise statements in server/mcpserver/server.py discard the causal exception chain: Line 1112: raise ValueError(str(e)) → raise ValueError(str(e)) from e Line 451: raise ResourceError(....
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/2542
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:afc93214-1be5-2f2c-16f6-3ad131511f9f |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | D72A:6972A:1816A3E:206D8C5:6A596F5D |
| html-safe-nonce | 746a110d91407555474f392a9ac0e4daa4e5ebb677b969e536f11dca3e15de2f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENzJBOjY5NzJBOjE4MTZBM0U6MjA2RDhDNTo2QTU5NkY1RCIsInZpc2l0b3JfaWQiOiI0MTkzNjEzNzc0NzY5OTc1MTMzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 102acddf85996f655f9c7cfc35eb4eb5374c4ed6792aa4af25c884e77978e9a5 |
| hovercard-subject-tag | pull_request:3627773171 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/modelcontextprotocol/python-sdk/pull/2542/files |
| twitter:image | https://avatars.githubusercontent.com/u/236632453?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/236632453?s=400&v=4 |
| og:image:alt | Summary Two raise statements in server/mcpserver/server.py discard the causal exception chain: Line 1112: raise ValueError(str(e)) → raise ValueError(str(e)) from e Line 451: raise ResourceError(.... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | a540949572872b935b393b36db38922db390ae71c859537d741b8f3eb7e545b5 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/modelcontextprotocol/python-sdk git https://github.com/modelcontextprotocol/python-sdk.git |
| octolytics-dimension-user_id | 182288589 |
| octolytics-dimension-user_login | modelcontextprotocol |
| octolytics-dimension-repository_id | 862584018 |
| octolytics-dimension-repository_nwo | modelcontextprotocol/python-sdk |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 862584018 |
| octolytics-dimension-repository_network_root_nwo | modelcontextprotocol/python-sdk |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 624bb50a7497aa346bef8cc3743af408a9ea10ca |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width