Skip to content

Stale metaschema resolution after $schema and $id URI changes #710

@davieshq

Description

@davieshq

Summary

After updating $schema and $id URIs across a large schema library (~80 files), the jsonschema test command reports a stale metaschema identifier that no longer exists in any schema file.

Steps to reproduce

  1. Start with a schema library where all files use a custom dialect as their $schema:

    { "$schema": "https://example.com/v2/dialect.json", "$id": "https://example.com/v2/asset.json" }
  2. Update all files to use the standard 2020-12 dialect and new $id URIs:

    { "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://example.com/v3/asset.json" }
  3. Rename the directory from v2/ to v3/ and update all --resolve paths accordingly.

  4. Verify with grep that no file contains the old URI (example.com/v2/dialect.json) — confirmed clean.

  5. Run jsonschema test tests/v3/asset/ --resolve v3/asset.json --resolve v3/dialect.json [... all other resolves]

Expected behaviour

All tests pass, since the target schema (asset.json) now uses $schema: https://json-schema.org/draft/2020-12/schema.

Actual behaviour

error: Could not resolve the metaschema of the schema
  at identifier https://example.com/v2/dialect.json
  at file path tests/v3/asset/asset.test.json

This is likely because you forgot to import such schema using `--resolve/-r`

The old dialect URI (v2/dialect.json) is referenced in the error, but does not exist in any file on disk. Other test suites (e.g. kinship.test.json) targeting simpler schemas pass without issue.

Environment

  • jsonschema CLI: installed via pnpm (latest as of April 2026)
  • Node: v22.22.1
  • OS: Ubuntu 24.04 (WSL2)

Context

This was encountered during the INHERIT open estate data standard's v2→v3 migration. The affected schema (asset.json) uses allOf + if/then composition referencing 5 category sub-schemas — it's the most complex schema in the library, which may be relevant to reproduction.

The issue may be related to internal caching of metaschema resolution during a single jsonschema test run, where earlier resolved schemas (which pass) establish a resolution context that persists for later schemas.

Workaround

Not yet found — clearing node_modules/.cache did not help. The schema files themselves are verified correct.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions