Skip to content

Draft 2020-12 relative JSON Pointer index manipulation is rejected #1533

Description

@dev-willbird1936

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions