Skip to content

Reject negative array indices in JSON pointers - #427

Open
fhgffy wants to merge 1 commit into
python-jsonschema:mainfrom
fhgffy:fix-negative-pointer-index-20261009
Open

fhgffy wants to merge 1 commit into
python-jsonschema:mainfrom
fhgffy:fix-negative-pointer-index-20261009

Conversation

@fhgffy

@fhgffy fhgffy commented Oct 9, 2026

Copy link
Copy Markdown

Resolver.lookup("#/-1") currently resolves to the last array element. Python's negative indexing leaks through Resource.pointer, even though JSON Pointer array indices are unsigned under RFC 6901 section 4.

Reject negative indices with PointerToNowhere. Object members named "-1" still resolve normally. The regression tests cover three negative indices and the object-key case; the three array cases fail on the original code.

This is separate from #387, which handles tokens that cannot be converted to an integer.

Validation on Python 3.14:

  • Full suite, including the referencing-suite submodule: 507 passed, 132 xfailed, 406 subtests passed.
  • Ruff checks and formatting, Pyright, and sdist/wheel builds passed.

This branch has not been deployed

No deployments
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