python-jsonschema / python-jsonschema/jsonschema
Draft 2020-12 relative JSON Pointer index manipulation is rejected
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5k
- Forks
- 671
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 10
Description
Draft 2020-12 references Relative JSON Pointer draft-bhutton-00, which permits
an optional +N or -N index-manipulation suffix after the leading
non-negative integer. jsonschema currently applies the older
draft-handrews-01 parser to Draft 2020-12 as well, so valid values such as
0+1/foo are rejected.
Minimal reproduction:
from jsonschema import Draft202012Validator, FormatChecker
schema = {"type": "string", "format": "relative-json-pointer"}
validator = Draft202012Validator(schema, format_checker=FormatChecker())
validator.validate("0+1/foo")
Actual behavior: validation raises FormatError because +1/foo is passed to
the ordinary JSON Pointer parser and does not begin with /.
Expected behavior: Draft 2020-12 accepts valid index-manipulation forms,
including 0+1, 0+1/foo, 1-2/bar, 0-0, and 0-1#. Draft 7 and Draft
2019-09 should continue rejecting the newer syntax.
Specification:
https://json-schema.org/draft/2020-12/relative-json-pointer
Reproduced against current main at
81f7a761cbaca107d3d261c1288155655b98ba08.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Draft202012Validator's relative-json-pointer format handling and FormatChecker, then compare how Draft 7 and Draft 2019-09 process the same values. Reproduce the listed examples and add coverage showing the accepted 2020-12 forms while older drafts continue rejecting them.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 75/100