Repository navigation
test(schema): validate guide examples by method - #3039
Open
connorburgess wants to merge 2 commits into
Open
connorburgess wants to merge 2 commits into
connorburgess wants to merge 2 commits into
Conversation
The guide check validates params against the named method's schema and falls back to the root schema when the method has none. The v1 root accepts any method name through its extension variants, so an example with a misspelled method such as session/promt passed without its params being checked. Only extension methods lack a payload schema, and their names start with an underscore. Require that for any method the schema does not define. All current guide examples pass. The v2 root already rejects unknown methods.
This branch has not been deployed
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.
The guide-example checker accepts malformed v1 requests because the root schema validates a union of payloads without selecting one by method. For example,
session/promptpasses withsessionIdmissing orpromptset to a string.Validate known request and notification params against the payload definition selected by method and message kind. Routing comes from the published schema unions and annotations, including protocol-level notifications and Draft proxy methods. Regression cases cover malformed payloads, message kinds, omitted params and extension compatibility. CONTRIBUTING documents the validation boundary.
Published schemas and protocol behavior are unchanged. Responses still use root validation because guide examples do not record their originating requests. This complements the v2 method-aware envelopes in #2932 and addresses the v1 validation limitation noted in #2981.
Validation on
8231f18a2732cc91246423439e4edec1fb0e57bd:npm run test:json-schema: 37 groups pass, including 402 complete guide examples across all four publications.npm run check: passes Clippy, formatting, spellcheck, Rust tests and schema tests.git diff --check: passes.These are local validation results.
Update: unknown method names (
0c26eb5)The first commit falls back to the root schema when a method has no payload schema. The v1 root accepts any method name through its extension variants, so an example with a misspelled method such as
session/promtpassed without its params being checked.Only extension methods lack a payload schema, and their names start with an underscore. The second commit requires that for any method the schema does not define, and CONTRIBUTING states the rule. The v2 root already rejects unknown methods.
Validation on
0c26eb5e(local results):v1/schema.jsonandv1/schema.unstable.json.npm run test:json-schema: 37 groups pass. Every existing guide example still passes.npm run format:checkandnpm run spellcheck: pass.JavaScript and Markdown only, so the Rust checks were not rerun for this commit.