Repository navigation
Conversation
Eleven invalid-selector tests for queries that stop early or put a token where the grammar does not allow one. A hand-written parser can crash on these instead of reporting a syntax error, and the suite did not cover them yet: - basic: the empty query (RFC 9535 section 2.2.1 requires "$"), a token directly after the root ($1, $*, $$), an unclosed bracketed selection ($[*) and function call syntax outside a filter ($.a.length()) - filter: an unclosed filter selector with and without an expression ($[?, $[?@.a==1), an empty filter expression ($[?]) and an unclosed parenthesized expression ($[?(@.a==1]) - match: a function call missing its closing parenthesis Each query is rejected by jsonpath-rfc9535 and by python-jsonpath in strict mode, and the corrected form of each is accepted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Adds 11
invalid_selectortests for queries that end early or have a token where the grammar doesn't allow one. We found these while fixing an implementation (IgnacioGoldchluk/json_path#1) that raised internal exceptions on them instead of returning a syntax error. It passed the whole suite, so other hand-written parsers may have the same gap.""jsonpath-query = root-identifier segments,root-identifier = "$"(§2.2.1)$1segment$*child-segmentneeds"."before*$$segment$[*bracketed-selection$.a.length()function-expris only allowed inside filters$[?filter-selector,bracketed-selection$[?@.a==1bracketed-selection$[?]filter-selector = "?" S logical-expr$[?(@.a==1]paren-expr$[?match(@.a, 'a.*']function-exprEach test breaks exactly one rule. The corrected forms (
$[*],$[?@.a==1],$[?(@.a==1)],$[?match(@.a, 'a.*')]) are valid. I avoided cases that also run into another rule (for example$[?length(@.a, sincelength()must be compared anyway) and parenthesized comparables like$[?@.a==(1.All 11 are rejected by jsonpath-rfc9535 and by python-jsonpath in strict mode.
cts.jsonwas regenerated withbuild.shand only adds lines (715 → 726 tests).🤖 Generated with Claude Code