Repository navigation
Conversation
adimalkar
requested review from
DarkSharpness,
Seven-Streams and
Ubospica
as code owners
October 9, 2026 02:28
Only the built-in formats compile to a regex. Any other format was skipped by GenerateString without a word, so the string was generated unconstrained and the dropped keyword could not be noticed (mlc-ai#967). Warn in SchemaParser::ParseString, where the minLength/maxLength warning from mlc-ai#896 lives, so the JSON and XML tool-calling converters both report it. The grammar is unchanged: format is an annotation by default in JSON Schema 2020-12, and schema generators emit formats xgrammar does not implement (pydantic's password, binary, path), so rejecting them would break schemas that compile today.
Seven-Streams
force-pushed
the
fix/warn-unknown-string-format
branch
from
October 17, 2026 14:42
b1a836b to
9ae4fc1
Compare
Seven-Streams
approved these changes
Oct 17, 2026
Contributor
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
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.
Fixes #967
What
A string schema whose
formatisn't one of the built-in formats compiled without any message, and the format was then ignored.{"type": "string", "format": "non_existing_format"}accepts"hello", so a constraint the schema asked for disappears and nobody notices.This PR logs a warning when that happens:
Why a warning and not an error
The issue asks for a compile-time error. I went with a warning, as explained in #967 (comment):
formatis an annotation by default, and validators may ignore formats they don't know. The existing tests from Warn when pattern is combined with minLength/maxLength in string schemas (silently dropped today) #896 already treat an unrecognized format as "a plain annotation".passwordforSecretStr,binaryforbytesandpathforPath. An error would make those schemas, which compile today, fail.Glad to switch to an error, or an error only under
strict_mode, if maintainers would rather.How
The warning lives in
SchemaParser::ParseString, next to theminLength/maxLengthwarning from #896, for the same reason that one does: every converter goes throughParseString, including the XML tool-calling converter, which overridesGenerateString. It reusesJSONSchemaConverter::IsBuiltinFormat. It's an unconditionalXGRAMMAR_LOG(WARNING)rather thanWarnUnsupportedKeywords, because nothing calls that function withverbose=true, so its warnings never print.The grammar doesn't change.
Tests
Added to
tests/python/test_json_schema_converter.py, next to the #896 tests and using the same_compile_and_capturehelper:password, combined withpattern, and combined withmaxLengthemail,date,date-time,uuid,uri) don't warnqwen_xml) warns tooLocally,
tests/python/test_json_schema_converter.pygives 627 passed. The wholetests/pythondirectory gives 4524 passed. The only 26 failures are intest_builtin_structural_tag_alignment.pyand come from the optionalcohere_melodypackage, which isn't installed here.pre-commitandruff checkpass.