Repository navigation
fix(unstable-v2): enforce two schema limits in the Rust types - #2921
Merged
Merged
Conversation
The JSON Schema states several limits that the Rust types did not check. Enforce the two where a wrong value does harm: - `TerminalSize.cols` and `rows` are `NonZeroU16`. A terminal cannot have zero columns or rows. `size` is a tolerant patch field, so a zero size is not applied, as with a location's `line`. - A `session/request_permission` request with an empty `options` list fails to deserialize. A Client cannot answer a request that offers nothing to select. The other schema-only limits stay unchecked on purpose. They are on display data and hints, or the spec lets the receiver choose whether to reject (an empty `prompt`). The generated schema changes in two descriptions only.
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
The JSON Schema states several limits that the Rust types did not check, so a Rust receiver accepted values that a schema-validating receiver rejects.
This enforces the two where a wrong value does harm, and leaves the rest tolerant on purpose.
Changes
TerminalSize.colsandrowsareNonZeroU16. A terminal cannot have zero columns or rows.sizeis a tolerant patch field, so a zero size is not applied. A tool call location'slinealready works this way.TerminalSize::newtakes the non-zero types.session/request_permissionrequest with an emptyoptionslist fails to deserialize, so the Agent gets an error. A Client cannot answer a request that offers nothing to select.Left unchecked
title, annotationpriority, the option lists of elicitation forms and config options, and diffchanges.promptandsystemPromptcontent: the spec says an Agent MAY reject these, so the type does not decide for it.Checks
cargo fmtpass. Tests that read a permission request with no options now offer one.