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".
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.
npm i -D ajv-cli ajv-formats
ajv validate -c ajv-formats -s schema.json -d config.jsonSelect the right draft or relax strict mode
Pass the matching spec, or disable strict mode only if you cannot change the schema.
ajv validate --spec=draft2020 -s schema.json -d config.json
# or, as a last resort
ajv validate --strict=false -s schema.json -d config.jsonHow to prevent it
- Register ajv-formats whenever schemas use standard formats.
- Match ajv's
--specto the schema's$schemadraft. - Prefer fixing the schema over disabling strict mode.