Repository navigation
common : gracefully fallback on unsupported regex patterns in JSON schema - #26939
Conversation
|
/bot review |
Automated code reviewReading the surrounding parser to confirm the escape-handling interaction: the grammar parser's Here is the review. Code review: PR #26939 — graceful fallback for unsupported regex patternsScope: single-purpose change to Will slow the review(point 1) Repetition quantifiers are not validated for negative or Since the PR explicitly sets out to "address other lingering regex parsing issues," add a guard right after the (point 2) Nits(point 3) The full- (point 4) TestsThe new test cases cover the right things: unanchored degradation, partial-conversion rule leakage (the This review was generated automatically by pi coding agent using |
…hema (ggml-org#26939) (cherry picked from commit dc64a16)
Overview
Fallback unsupported regex patterns in JSON schemas to a JSON string.
Additional information
Some regex patterns cannot be properly supported by the grammar sampler, for example:
.*are incorrect and result in unconstrained output.Rather than attempting to support these expressions, it is easier to degrade gracefully to any JSON string and rely on the model to produce valid output. If the output is invalid, the client can address it through a self-correcting loop.
This also handles unsupported PCRE shorthands, although nothing precludes true grammar support. Current open PRs perform naive replacement, which is an incomplete solution.
I also took the liberty to address other lingering regex parsing issues.
Supersedes #26931
Supersedes #25308
Supersedes #22606
Supersedes #20470
Fixes #26930
Fixes #25284
Invalid patterns are still raised as errors.
Requirements