Skip to content

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

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

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

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 linter rules were incorrectly flagging/removing default and examples values when they appeared as siblings to $ref in Draft 4, 6, and 7 schemas.

This PR adds an early-return guard in both ValidDefault::condition() and ValidExamples::condition() that skips linting when $ref is present and the schema dialect is not 2019-09 or 2020-12 (where $ref siblings are valid and should continue to be linted).

Fixes sourcemeta/jsonschema#425

Review & Testing Checklist for Human

  • Verify the vocabulary-based guard logic is correct: The check uses a negative condition (!2020-12 && !2019-09) to identify old drafts. Confirm this is the right approach — note that if a future draft introduces a new vocabulary URI, it would fall into the "ignore siblings" path by default until updated.
  • Verify the 2019-09/2020-12 "still linted" tests are meaningful: These tests use a no-op lambda callback (instead of transformer_callback_error) and assert that invalid default/examples are removed. Confirm the expected schemas (with default/examples stripped) are correct.
  • Run make locally and confirm all 7 test suites pass and no formatting diff remains.

Notes

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

For 2019-09 and 2020-12, siblings to $ref are valid and continue
to be linted as before.

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