Repository navigation
fix: Resolve $ref to anchors, URN base URIs and ids beside $ref in Draft 2019-09 - #970
Merged
DannyvdSluijs merged 1 commit intoNov 24, 2026
Conversation
Roman3349
force-pushed
the
fix/ref-identifier-resolution
branch
2 times, most recently
from
October 18, 2026 00:37
68b1eb0 to
c357098
Compare
Roman3349
force-pushed
the
fix/ref-identifier-resolution
branch
from
October 24, 2026 17:40
c357098 to
0a4aa67
Compare
This was referenced Oct 24, 2026
Roman3349
force-pushed
the
fix/ref-identifier-resolution
branch
from
November 23, 2026 23:12
0a4aa67 to
d1fb2f0
Compare
Contributor
Author
…aft 2019-09
A $ref whose fragment is a plain name rather than a JSON pointer could not
be resolved: fragment-only ids (draft-04 to draft-07) and $anchor (draft
2019-09) were never registered, and the fragment was rewritten to a JSON
pointer ("#foo" became "#/foo"). Resolving such a $ref therefore threw
UnresolvableJsonPointerException, even for valid data. Up to 6.13.1 the
Draft-06/07/2019-09 constraints swallowed that exception in strict mode,
so the $ref passed silently; since jsonrainbow#944 it surfaces.
- SchemaStorage registers anchors and resolves a plain-name fragment
against them. A fragment-only id no longer changes the base uri.
- From Draft 2019-09 on, a $ref is resolved against the $id next to it,
as the dialect declared by $schema says. Up to draft-07 the sibling
$id stays ignored.
- UriResolver resolves a fragment-only reference against the base without
its fragment, and no longer takes a base without an authority (urn:)
for a local file path.
- Removes the test suite skips that now pass, including those added in
jsonrainbow#944 for refs that could not be resolved.
Signed-off-by: Roman Ondráček <mail@romanondracek.cz>
Roman3349
force-pushed
the
fix/ref-identifier-resolution
branch
from
November 24, 2026 14:31
d1fb2f0 to
cce66c9
Compare
DannyvdSluijs
approved these changes
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A
$refwhose fragment is a plain name (an anchor) rather than a JSON pointer could not be resolved. Fragment-only ids ("id": "#foo"/"$id": "#foo"in Draft-04 to Draft-07) and$anchor(Draft 2019-09) were never registered. On top of that,expandRefs()rewrote the fragment into a JSON pointer, so#foobecame#/foo, and resolving it threwUnresolvableJsonPointerException, even for valid data. Up to 6.13.1, the Draft-06/07/2019-09RefConstraints swallowed that exception in strict mode, so such a$refpassed silently; since #944 it surfaces.URN base URIs were broken as well.
UriResolver::resolve()tookurn:uuid:…for a local file path and prefixed it withfile://<cwd>/, andgenerate()would have producedurn://uuid:…anyway.Changes:
SchemaStorageUnresolvableJsonPointerException.$refis resolved against the$idnext to it. The dialect is taken from$schemaand inherited by subschemas. Up to Draft-07 the sibling$idstays ignored. Without$schemathe previous behavior is kept.UriResolverurn:) is no longer treated as a local file path. A single-letter scheme still is, to keep Windows drive paths (C:\…) working.JsonSchemaTestSuiteTestRelated Issue
Related to #916 (an unresolvable
$refpassing silently). Follow-up to #944 (released in 6.14.0), which made an unresolvable$refthrow. With this PR, refs to anchors, fragment-only ids and URN-based ids resolve instead of throwing, which restores the Draft-06/07 strict results that dropped in 6.14.0.Type of Change
Checklist
Additional Notes
Rebased onto 6.14.0. With #944 merged, the "valid" variants of the affected test suite cases started throwing and were skipped; they pass again with this PR, so those skips are removed together with their "invalid" twins.