Skip to content

Avoid top-level $ref in Draft 7 and older#170

Open
jviotti wants to merge 1 commit into
mainfrom
no-top-level-ref
Open

Avoid top-level $ref in Draft 7 and older#170
jviotti wants to merge 1 commit into
mainfrom
no-top-level-ref

Conversation

@jviotti

@jviotti jviotti commented Nov 17, 2025

Copy link
Copy Markdown
Member

As per the specification, a subschema defining $ref is a "ref object"
and EVERY other property MUST be completely ignored.

Many implementations (including Blaze), tried to be a bit lenient in
these cases, mainly at the root of a schema.

However, after discussing some pathological cases, the TSC came into
agreement that ANY attempt to make this work, even at the root, can lead
to undefined behavior. Therefore, many implementations, including Blaze,
will now be more strict on this, completely rejecting Draft 7 and older
schemas with a top-level $ref.

In this PR, I update a few of the test cases that hit this problem. I
modified them to make them work exactly like before, so we are not
testing more or less than we did before given the workarounds we had in
place.

Signed-off-by: Juan Cruz Viotti jv@jviotti.com

As per the specification, a subschema defining `$ref` is a "ref object"
and EVERY other property MUST be completely ignored.

Many implementations (including Blaze), tried to be a bit lenient in
these cases, mainly at the root of a schema.

However, after discussing some pathological cases, the TSC came into
agreement that ANY attempt to make this work, even at the root, can lead
to undefined behavior. Therefore, many implementations, including Blaze,
will now be more strict on this, completely rejecting Draft 7 and older
schemas with a top-level `$ref`.

In this PR, I update a few of the test cases that hit this problem. I
modified them to make them work exactly like before, so we are not
testing more or less than we did before given the workarounds we had in
place.

Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
@michaelmior

Copy link
Copy Markdown
Contributor

It's unclear why the properties are removed from yamllint.

@jviotti

jviotti commented Nov 18, 2025

Copy link
Copy Markdown
Member Author

They were getting ignored before given $ref (which overrides sibling keywords in Draft 7 and older) anyway. I removed them to keep the same semantics as before. i.e. Blaze would be generating the same instructions for this schema before/after the change.

@michaelmior

Copy link
Copy Markdown
Contributor

That makes sense. LGTM

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.

2 participants