Skip to content

test(schema): validate guide examples by method - #3039

Open
connorburgess wants to merge 2 commits into
agentclientprotocol:mainfrom
connorburgess:cb/validate-v1-guide-payloads
Open

connorburgess wants to merge 2 commits into
agentclientprotocol:mainfrom
connorburgess:cb/validate-v1-guide-payloads

Conversation

@connorburgess

@connorburgess connorburgess commented Dec 5, 2026 •

Copy link
Copy Markdown

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/prompt passes with sessionId missing or prompt set 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:

  • Before the fix, the two v1 regression groups fail; the v2 groups pass.
  • 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/promt passed 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):

  • With the new assertions and without the checker change, the "guide examples use the named method's payload" group fails for v1/schema.json and v1/schema.unstable.json.
  • npm run test:json-schema: 37 groups pass. Every existing guide example still passes.
  • npm run format:check and npm run spellcheck: pass.

JavaScript and Markdown only, so the Rust checks were not rerun for this commit.

@connorburgess
connorburgess requested a review from a team as a code owner December 5, 2026 04:37
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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant