Invalid $ref and $schema version usage, leading to checks being noops across a number of schemas

Open
#3,102 12 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
javascript, json
Domain
testing, tooling

Research direction

Start by running schemasafe across the affected schemas, then inspect github-workflow.json, prettierrc.json, and stale.json at the linked $ref and $schema locations. Compare their behavior with the JSON Schema draft-07 ref tests. Done means the affected schemas no longer contain invalid $ref/$schema usage that causes sibling checks to be ignored.

Written by the indexing model from the issue text.

Description

Bug Build Server
Area with issue?

JSON Schema

✔️ Expected Behavior

See https://github.com/ExodusMovement/schemasafe/issues/158#issuecomment-1653608034

In draft-07 and below (below 2019-09), $ref makes all sibling keywords ignored: https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-01#section-8.3

image

Upstream testsuite: https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/8cdfac41e37527795879e480a483997cbd6188f3/tests/draft7/ref.json#L145-L177

❌ Actual Behavior

A number of schemas here don't check what they are supposed to, e.g. the following checks are noops/ignored in all JSON Schema implementations that pass on upstream testsuite:

  1. github-workflow.json:

https://github.com/SchemaStore/schemastore/blob/ac57222a5fba1f5b61643af38b1d402477a2ae83/src/schemas/json/github-workflow.json#L3

https://github.com/SchemaStore/schemastore/blob/ac57222a5fba1f5b61643af38b1d402477a2ae83/src/schemas/json/github-workflow.json#L1017-L1031

properties is a noop/ignored, with all nested checks.

  1. prettierrc.json:

https://github.com/SchemaStore/schemastore/blob/ac57222a5fba1f5b61643af38b1d402477a2ae83/src/schemas/json/prettierrc.json#L2

https://github.com/SchemaStore/schemastore/blob/ac57222a5fba1f5b61643af38b1d402477a2ae83/src/schemas/json/prettierrc.json#L378-L382

type is a noop/ignored.

  1. stale.json:

https://github.com/SchemaStore/schemastore/blob/ac57222a5fba1f5b61643af38b1d402477a2ae83/src/schemas/json/stale.json#L3-L4

https://github.com/SchemaStore/schemastore/blob/ac57222a5fba1f5b61643af38b1d402477a2ae83/src/schemas/json/stale.json#L91-L103

type and properties are noops/ignored, with all nested checks.

  1. A number of other schemas.

    The ones above are just examples, this seems wide-spread.

    Passing all schemas through schemasafe should highlight all issues — it refuses to compile such schemas in default configuration (unless schema mistakes are silenced).

YAML or JSON file that does not work.

No response

IDE or code editor.

None

Are you making a PR for this?

No, someone else must create the PR.

Dominant language
JavaScript
Stars
3.9k
Forks
2.4k
Avg merge
12h 34m
Merged PRs (30d)
134

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SchemaStore/schemastore

All issues in SchemaStore/schemastore

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.