Skip to content
Latchkey

ajv "schema is invalid" error in CI

ajv rejected the schema itself (not the data). In strict mode it fails on unknown keywords, unknown formats, or a $schema draft it does not support, reporting "schema is invalid".

What this error means

ajv-cli aborts before validating data with "schema is invalid:" followed by details like "unknown format \"uri\" ignored" turned into an error, or "strict mode: unknown keyword".

ajv
Error: schema is invalid: data/properties/url/format must be equal to one of the
allowed values; strict mode: unknown format "uri"

Common causes

A format ajv does not know in strict mode

Formats like uri, email, and date-time live in ajv-formats; without it, strict mode treats the unknown format as an invalid schema.

A draft mismatch or unknown keyword

The schema's $schema targets a draft ajv is not set up for, or uses a keyword ajv does not recognize in strict mode.

How to fix it

Add ajv-formats for standard formats

Install and register ajv-formats (or pass -c ajv-formats to ajv-cli) so formats like uri are recognized.

Terminal
npm i -D ajv-cli ajv-formats
ajv validate -c ajv-formats -s schema.json -d config.json

Select the right draft or relax strict mode

Pass the matching spec, or disable strict mode only if you cannot change the schema.

Terminal
ajv validate --spec=draft2020 -s schema.json -d config.json
# or, as a last resort
ajv validate --strict=false -s schema.json -d config.json

How to prevent it

  • Register ajv-formats whenever schemas use standard formats.
  • Match ajv's --spec to the schema's $schema draft.
  • Prefer fixing the schema over disabling strict mode.

Frequently asked questions

What causes ""schema is invalid""?
Formats like uri, email, and date-time live in ajv-formats; without it, strict mode treats the unknown format as an invalid schema.
How do I fix "schema is invalid"?
Install and register ajv-formats (or pass -c ajv-formats to ajv-cli) so formats like uri are recognized.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card