Return Invalid Params for unknown prompts and missing prompt arguments - #517
Merged
koic merged 1 commit intoAug 15, 2026
Merged
Conversation
An unknown prompt name and a missing required prompt argument are client input errors, but prompts/get raised them with the default Internal Error (-32603). The tools/call, resources/read, and completion/complete siblings already return Invalid Params (-32602) for the same not-found and missing-input conditions (resources/read via ResourceNotFoundError, per SEP-2164). Add an explicit error_code so both map to -32602 while keeping the descriptive message and the existing instrumentation labels.
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
prompts/getreturns Internal Error (-32603) when the prompt name is unknown or a required argument is missing. Both are client input errors, so the JSON-RPC error code should be Invalid Params (-32602), which is what the sibling handlers already return for the same conditions.Current behavior
Requesting an unknown prompt:
{"jsonrpc":"2.0","id":1,"error":{"code":-32603,"message":"Internal error","data":"Prompt not found ghost"}}completion/complete(Server#complete), asked to complete an argument for that same unknown prompt, already returns -32602. The two handlers return different codes for the one condition.Why Invalid Params
The not-found and missing-input paths of the neighboring methods already map to -32602:
tools/callunknown tool, inServer#call_toolresources/readunknown resource, viaResourceNotFoundError, standardized to -32602 in SEP-2164completion/completeunknown prompt, inServer#completeprompts/getwas the only not-found path left on -32603.Change
Add an explicit
error_code: JsonRpcHandler::ErrorCode::INVALID_PARAMSat the twoprompts/getraise sites:Server#get_promptPrompt.validate_arguments!This follows the
ResourceNotFoundErrorpattern already in the tree: the wire code becomes -32602 and the descriptive message is surfaced, whileerror_typestays:prompt_not_found/:missing_required_argumentsso the existing instrumentation labels are unchanged.After:
{"jsonrpc":"2.0","id":1,"error":{"code":-32602,"message":"Prompt not found ghost","data":"Prompt not found ghost"}}Tests
Extended the two existing
prompts/geterror tests to assert the -32602 code; they fail on the current code and pass with the fix.bundle exec rakeis green (1701 runs, 0 failures), RuboCop reports no offenses, and the conformance baseline is unchanged.