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.
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.
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.
{
"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.