Skip to content

Support dot notation for list indices in skip verification paths - #28

Closed
bentsku wants to merge 1 commit into
aws-819-unpin-jsonpath-ngand-upgrade-to-18-by-making-localstackfrom
fix-skip-path-dot-index-notation
Closed

bentsku wants to merge 1 commit into
aws-819-unpin-jsonpath-ngand-upgrade-to-18-by-making-localstackfrom
fix-skip-path-dot-index-notation

Conversation

@bentsku

@bentsku bentsku commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Motivation

Stacked on #27.

Skip paths using dot notation for list indices, like $..aaa.1, $..aaa..0 or $..aaa.0..aab.1, never matched anything, on jsonpath-ng 1.7 or 1.9. jsonpath-ng only matches Fields against dicts. The existing tests didn't catch this because each dot-notation assertion ran after a bracket-notation assertion on the same session, which had already removed the values. Skip paths using this syntax have been silently not applied.

Changes

  • After parsing a skip path, replace digits-only Fields with a _FieldOrIndex node. It acts as a list index when applied to a list, and as a regular key otherwise. This has to be decided at match time, since $.a.1 and $.a.'1' parse to the same AST, so numeric dict keys keep working.
  • Rewrite the list skip-path tests to use a new session for every assertion, parametrized over bracket and dot notation. Add tests for numeric dict keys and out-of-range dot indices.

Known limitation: jsonpath-ng can't parse consecutive numeric fields like $..aaa.2.0, because 2.0 is lexed as a float. Use $..aaa.2[0] instead. This is noted in the docstring.

🤖 Generated with Claude Code

Skip paths like `$..aaa.1` or `$..aaa..0` never matched anything, as
jsonpath-ng only matches `Fields` against dicts. The existing tests did not
catch it, because they ran after a bracket-notation assertion on the same
session, which had already removed the values from the state.

Numeric fields are now replaced after parsing with a field that acts as a
list index when applied to a list, and as a regular key otherwise, since
`$.a.1` and `$.a.'1'` are parsed identically.

The tests now use a new session for every assertion.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bentsku
bentsku marked this pull request as draft October 7, 2026 23:09
@bentsku
bentsku added this pull request to stack #29 October 7, 2026 23:09
@bentsku
bentsku removed this pull request from stack #29 October 7, 2026 23:15
@bentsku

bentsku commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

Closing: $.a.1 isn't valid JSONPath (RFC 9535 requires bracket notation for indices), and no snapshot skip path in localstack uses it, so we won't add a custom dialect. The test cleanup (a new session per assertion, so tests can't pass on state already mutated by an earlier assertion) is folded into #27.

@bentsku bentsku closed this Oct 7, 2026
@bentsku
bentsku deleted the fix-skip-path-dot-index-notation branch October 7, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant