Skip to content

test(relative-json-pointer): add multi-digit prefix with interior zero#942

Open
vtushar06 wants to merge 1 commit into
json-schema-org:mainfrom
vtushar06:relative-json-pointer-interior-zero
Open

test(relative-json-pointer): add multi-digit prefix with interior zero#942
vtushar06 wants to merge 1 commit into
json-schema-org:mainfrom
vtushar06:relative-json-pointer-interior-zero

Conversation

@vtushar06

@vtushar06 vtushar06 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Following the methodology I used for ipv4 and uuid, I read draft-handrews-relative-json-pointer-01 section 3 and found the suite has no test for a multi-digit prefix with an interior zero - the spot where a hand-rolled integer scanner can go wrong.

The prefix grammar is non-negative-integer = %x30 / %x31-39 *( %x30-39 ), so after the first digit any digits are allowed, zeros included. 100 is valid (it is 1 then 00); only a leading zero is barred. The suite already has 120/foo/bar as a valid multi-digit prefix, but there the zero is the last digit, so it does not exercise a zero that is followed by another digit.

Changes

  • Added 1 test case across draft7, draft2019-09, draft2020-12, and v1.
  • 100 - a valid non-negative integer with a zero before another digit - valid.

Ecosystem Impact

  1. ajv-formats 3.0.1, Go santhosh-tekuri/jsonschema v6, Rust jsonschema 0.46.5: PASS (accept it).
  2. python-jsonschema 4.x: FAILS (rejects it). Its is_relative_json_pointer walks the string and runs if i > 0 and int(instance[i - 1]) == 0: return False. That guard is meant to catch a leading zero, but it fires on any zero followed by another digit, so 100, 1000, 205 are wrongly rejected while 120 (zero last) passes.

RFC References

Reproduction commands and the relative-json-pointer cross-implementation matrix are in my evidence repo: https://github.com/vtushar06/JSON-Schema-format-test-Evidence/blob/main/relative-json-pointer.md

Related: #965

@vtushar06 vtushar06 requested a review from a team as a code owner June 15, 2026 19:22
Copilot AI review requested due to automatic review settings June 15, 2026 19:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new conformance test case for the relative-json-pointer format to ensure multi-digit integer prefixes that include 0 are treated as valid across multiple test suites.

Changes:

  • Added a new “valid” test case for a multi-digit integer prefix containing 0
  • Applied the same test addition across v1 and draft7/draft2019-09/draft2020-12 optional format suites

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
tests/v1/format/relative-json-pointer.json Adds a new valid-case example for a multi-digit prefix containing 0
tests/draft7/optional/format/relative-json-pointer.json Mirrors the new valid-case example in the draft7 optional suite
tests/draft2020-12/optional/format/relative-json-pointer.json Mirrors the new valid-case example in the draft2020-12 optional suite
tests/draft2019-09/optional/format/relative-json-pointer.json Mirrors the new valid-case example in the draft2019-09 optional suite

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +100 to +102
"description": "multi-digit prefix with a zero followed by another digit",
"data": "100",
"valid": true

@jviotti jviotti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubled-checked and it looks correct!

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.

3 participants