Title: [v1.x] fix: catch PydanticUserError when generating output schema (pydantic 2.13 compat) by maxisbey · Pull Request #2435 · modelcontextprotocol/python-sdk · GitHub
Open Graph Title: [v1.x] fix: catch PydanticUserError when generating output schema (pydantic 2.13 compat) by maxisbey · Pull Request #2435 · modelcontextprotocol/python-sdk
X Title: [v1.x] fix: catch PydanticUserError when generating output schema (pydantic 2.13 compat) by maxisbey · Pull Request #2435 · modelcontextprotocol/python-sdk
Description: Backport of #2434 to v1.x. Pydantic 2.13.0 changed PydanticUserError's base class from TypeError to RuntimeError (pydantic/pydantic#12579). _try_create_model_and_schema was relying on except TypeError to catch PydanticInvalidForJsonSchema when a return type contains a field that can't be represented in JSON Schema (e.g. Callable). On pydantic 2.13.0 that exception now escapes, so registering such a tool crashes instead of falling back to unstructured output. This adds PydanticUserError to the except tuple so the fallback works on all supported pydantic versions. How Has This Been Tested? Covered by the existing test_structured_output_unserializable_type_error, which fails on pydantic 2.13.0 without this change. The highest resolution leg of the v1.x CI matrix exercises pydantic 2.13.0 directly. Breaking Changes None. Types of changes Bug fix (non-breaking change which fixes an issue) Checklist I have read the MCP Documentation My code follows the repository's style guidelines New and existing tests pass locally I have added appropriate error handling AI Disclaimer
Open Graph Description: Backport of #2434 to v1.x. Pydantic 2.13.0 changed PydanticUserError's base class from TypeError to RuntimeError (pydantic/pydantic#12579). _try_create_model_and_schema was relying on except Ty...
X Description: Backport of #2434 to v1.x. Pydantic 2.13.0 changed PydanticUserError's base class from TypeError to RuntimeError (pydantic/pydantic#12579). _try_create_model_and_schema was relying on excep...
Opengraph URL: https://github.com/modelcontextprotocol/python-sdk/pull/2435
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:36b7bc63-9c45-f60b-469a-9897c232b988 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DEEC:22AFD6:9CB6007:D3B7B3B:6A5E879B |
| html-safe-nonce | de3eed34c751c9f2e64edc26bfa9a82874e6c83313f301f8fac24e3ba67c5599 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERUVDOjIyQUZENjo5Q0I2MDA3OkQzQjdCM0I6NkE1RTg3OUIiLCJ2aXNpdG9yX2lkIjoiNTg4OTI4NTk5NzMxMDQxMjY5OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 457a075dcbc75fff8b8e9c988b6702c1f4a63d9b2b282029a6569e833e305efd |
| hovercard-subject-tag | pull_request:3523397699 |
| 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/2435/files |
| twitter:image | https://avatars.githubusercontent.com/u/224885523?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/224885523?s=400&v=4 |
| og:image:alt | Backport of #2434 to v1.x. Pydantic 2.13.0 changed PydanticUserError's base class from TypeError to RuntimeError (pydantic/pydantic#12579). _try_create_model_and_schema was relying on except Ty... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | e0c30ec4bc4cc128be7eee7ef869507723a2ac9916267b7e0d370b3580a5e7ba |
| 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 | 68ef39d284f7f48d37e751bc9bc0a9a4166228d5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width