Repository navigation
Conversation
|
This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3837. If a maintainer assigns you to #3837, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take. You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove |
Fixes #3837.
ResourceTemplate.from_functionwraps the handler inpydantic.validate_call, which combines URI parameter coercion with the handler call. When a URI parameter fails its type annotation (for exampleusers://abc/profileonuser_id: int), the resultingValidationErrorlands in theexcept Exceptionbranch ofResourceTemplate.create_resource, logging anERRORtraceback and returning-32603(Error creating resource from template ...) instead of-32602(Unknown resource: ...).from_functionalready builds the parameter model viafunc_metadata. This change keeps thatarg_modelon the template and validates extracted parameters against it increate_resourcebefore calling the unwrapped handler:ValidationErrorfrom parameter coercion raisesResourceNotFoundError(f"Unknown resource: {uri}")chained to theValidationError, answering-32602and logging a singleINFOline without a traceback (matching an unmatched URI or aResourceSecurityErrorrejection).getattr(self.fn, "__wrapped__", self.fn)so custom parameter validators run once per read whileResourceTemplate.fnkeeps its existingvalidate_callwrapper.ValidationErrorraised inside the handler body, or a custom parameter validator raising an exception other thanValueError/AssertionError(orResourceError/MCPError), still takes theUnexpectedResourceErrorcrash path (-32603and anERRORlog with traceback).