Skip to content

Support Draft 2020-12 relative JSON Pointer index manipulation#1534

Open
dev-willbird1936 wants to merge 1 commit into
python-jsonschema:mainfrom
dev-willbird1936:prep/fnd-0240-relative-json-pointer
Open

Support Draft 2020-12 relative JSON Pointer index manipulation#1534
dev-willbird1936 wants to merge 1 commit into
python-jsonschema:mainfrom
dev-willbird1936:prep/fnd-0240-relative-json-pointer

Conversation

@dev-willbird1936

Copy link
Copy Markdown

Fixes #1533.

Summary

  • Add Draft 2020-12 support for Relative JSON Pointer index manipulation.
  • Keep the Draft 7 and Draft 2019-09 checker behavior unchanged.

Root cause

The same checker was registered for Draft 7, Draft 2019-09, and Draft 2020-12, but it implements the older draft-handrews-relative-json-pointer-01 syntax. Draft 2020-12 references draft-bhutton-relative-json-pointer-00, which adds an optional +N or -N index manipulation after the initial non-negative integer.

The old checker passes the signed suffix to jsonpointer.JsonPointer, so valid values such as 0+1/foo are rejected because the remainder does not begin with /.

Fix

Register a Draft 2020-12-specific checker that parses the initial integer and optional signed offset before validating the remaining JSON Pointer. Retain the existing function for Draft 7 and Draft 2019-09.

Tests

  • Positive regression covers 0+1, 0+1/foo, 1-2/bar, 0-0, and 0-1#.
  • Negative controls prove older drafts still reject index manipulation.
  • Adversarial controls reject malformed offsets and remainders.
  • The full jsonschema test suite and targeted ruff checks pass.

Checklist

  • The change includes positive and nearby negative tests.
  • Targeted and broader tests pass.
  • The change is limited to the format checker and its tests.
  • Documentation and changelog changes are not required for this focused correction.

@read-the-docs-community

read-the-docs-community Bot commented Jul 25, 2026

Copy link
Copy Markdown

Documentation build overview

📚 python-jsonschema | 🛠️ Build #33759981 | 📁 Comparing 9e0ef8a against latest (81f7a76)

  🔍 Preview build  

1 file changed
± _modules/jsonschema/_format/index.html

@dev-willbird1936
dev-willbird1936 force-pushed the prep/fnd-0240-relative-json-pointer branch 5 times, most recently from 7b8d476 to 66eb0db Compare July 25, 2026 23:25
@dev-willbird1936
dev-willbird1936 force-pushed the prep/fnd-0240-relative-json-pointer branch from 66eb0db to 9e0ef8a Compare July 25, 2026 23:26
@Julian

Julian commented Jul 25, 2026

Copy link
Copy Markdown
Member

The first step here should be a PR to https://github.com/json-schema-org/JSON-Schema-Test-Suite !

@dev-willbird1936

Copy link
Copy Markdown
Author

I opened the prerequisite implementation-neutral test-suite coverage in json-schema-org/JSON-Schema-Test-Suite#1032. I will keep this implementation PR aligned with the outcome there.

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.

Draft 2020-12 relative JSON Pointer index manipulation is rejected

2 participants