fix(json_schema): keep pattern alternations inside JSON quotes - #268
Open
original4422 wants to merge 1 commit into
Open
fix(json_schema): keep pattern alternations inside JSON quotes#268original4422 wants to merge 1 commit into
original4422 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Author
|
Hi @RobinPicard, when you have a chance, could you please review this PR and let me know if any changes are needed? Thanks! |
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
JSON Schema string patterns with a top-level alternation were interpolated directly between JSON quote characters. That allowed the alternation to bind across the quotes, rejecting valid values while accepting malformed JSON.
This change wraps the interpolated pattern in a non-capturing group inside the quotes. It preserves user capture numbering while keeping every alternative within the JSON string. The regression test covers unanchored and paired-anchor alternations, malformed missing-quote inputs, a simple pattern, and an already-parenthesized pattern.
Fixes #267
Validation
cargo test string_pattern_alternations_stay_inside_json_quotes -- --nocapturecargo test json_schema -- --nocapturecargo testcargo fmt -- --checkcargo clippy --all-targets --features python-bindings -- -D warningsmaturin developpytest tests/test_json_schema.py tests/test_imports.py -vv(10 passed)pre-commit run --all-filespassed every hook exceptcargo-fmt, which could not start because this host uses Homebrew Cargo without rustup and therefore cannot resolvecargo +nightly. The equivalent stablecargo fmt -- --checkpassed; the changed code does not involve the repository formatting options that are nightly-only.Checklist
maincommit.