ajv "must have required property" validation error in CI
ajv validated your data against a JSON Schema and a required field was absent. It reports "must have required property 'X'" with the JSON path to the object that is missing it.
What this error means
ajv-cli exits non-zero with "data must have required property 'version'" (or similar) and an instancePath. The document parsed fine but does not satisfy the schema.
ajv
config.json invalid
[
{
"instancePath": "",
"schemaPath": "#/required",
"keyword": "required",
"params": { "missingProperty": "version" },
"message": "must have required property 'version'"
}
]Common causes
A mandatory field is missing from the data
The schema lists the property in required, but the config file never sets it, so validation fails.
The field exists but under the wrong name or level
A typo or wrong nesting means the required key is not where the schema expects it, so ajv still reports it missing.
How to fix it
Add the required field to the data
- Read the
instancePathandmissingPropertyfrom ajv's output. - Add the property at that path with a valid value.
- Re-run
ajv validateto confirm.
Terminal
ajv validate -s schema.json -d config.jsonRelax the schema if the field is genuinely optional
If the property should not be mandatory, remove it from the schema's required array.
schema.json
{
"type": "object",
"required": ["name"],
"properties": { "name": { "type": "string" }, "version": { "type": "string" } }
}How to prevent it
- Keep the schema and the documented config in sync when fields change.
- Validate configs against the schema in a pre-commit hook.
- Use
instancePathin errors to jump straight to the missing field.
Related guides
ajv "must NOT have additional properties" in CIFix ajv "must NOT have additional properties" in CI - the data contains a key the schema does not define whil…
ajv "schema is invalid" error in CIFix ajv "schema is invalid" in CI - the JSON Schema itself does not conform to its meta-schema, or uses a dra…
check-jsonschema "Additional properties are not allowed" in CIFix check-jsonschema "Additional properties are not allowed ('X' was unexpected)" in CI - the document has a…