Skip to content

Don't lint default and examples siblings to $ref in Draft 7 and older#597

Open
staging-devin-ai-integration[bot] wants to merge 1 commit intomainfrom
evalon/blaze-dont-a1cce264
Open

Don't lint default and examples siblings to $ref in Draft 7 and older#597
staging-devin-ai-integration[bot] wants to merge 1 commit intomainfrom
evalon/blaze-dont-a1cce264

Conversation

@staging-devin-ai-integration
Copy link

Don't lint default and examples siblings to $ref in Draft 7 and older

Summary

In JSON Schema Draft 7 and older, implementations MUST ignore any keyword that is a sibling to $ref. The ValidDefault and ValidExamples lint rules were incorrectly validating (and potentially removing) default/examples keywords when they appeared alongside $ref in Draft 4, Draft 6, and Draft 7 schemas.

This PR adds an early-return check in both ValidDefault::condition() and ValidExamples::condition(): if the schema object defines $ref and the active vocabulary is not 2019-09 or 2020-12 (where $ref siblings are processed normally), the lint rule is skipped entirely.

The check is placed after the existing vocabulary gate, so it only applies to the five known draft vocabularies. If the vocabulary is not 2019-09/2020-12 at that point, it must be Draft 4/6/7, which correctly maps to the "ignore siblings" behavior.

Fixes: sourcemeta/jsonschema#425

Review & Testing Checklist for Human

  • Verify the negative-check approach (!2020-12 && !2019-09) is the preferred pattern in this codebase vs. positively checking for old draft URIs — the logic is equivalent given the earlier vocabulary gate, but confirm it matches project conventions
  • Confirm that existing tests for 2020-12 with $ref + valid default/examples siblings (tests valid_default_10, valid_default_11, valid_examples_11, valid_examples_12) still pass and aren't affected by the new guard
  • Run make end-to-end to confirm all 7 test suites pass with no formatting drift

Notes

In Draft 7 and older, JSON Schema implementations MUST ignore any
keyword that is a sibling to $ref. Update ValidDefault and ValidExamples
lint rules to skip validation when default/examples are siblings to
$ref in Draft 4, Draft 6, and Draft 7.

For 2019-09 and 2020-12, $ref siblings are processed normally, so the
lint rules still validate and remove invalid default/examples values.

Co-Authored-By: bot_apk <apk@cognition.ai>
@staging-devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

lint: default and $ref causing early process exit

0 participants