JSON Schema — additionalProperties false rejects extra fields
JSON Schema validation fails because additionalProperties is set to false and the input contains fields not defined in the properties object.
Symptoms
- error: Additional properties are not allowed
- Validation passes when extra fields are removed
- The schema works in strict mode but not lenient mode
Possible causes
- The input includes fields not listed in the schema properties
- additionalProperties is false but the input has extra metadata
- The schema was updated to remove a field but clients still send it
Diagnosis steps
Diff the input against the schema properties
node -e "console.log(Object.keys(input).filter(k=>!schema.properties[k]))"Interpretation
Lists the extra fields that trigger the rejection.
Check the additionalProperties setting
grep "additionalProperties" schema.jsonInterpretation
If false, no extra fields are allowed.
Root cause
The schema sets additionalProperties to false, so any field not in properties is rejected, even if it is valid JSON.
Fix
Remove the extra fields from the input, add them to the schema properties, or set additionalProperties to true or a schema to allow them.
Verify the fix
Validate the corrected input and confirm it passes; verify extra fields are still rejected if additionalProperties remains false.
Symptom walkthrough
JSON Schema validation fails because additionalProperties is set to false and the input contains fields not defined in the properties object. The error appears in production but may not surface in local development because the conditions that trigger it depend on the deployment environment or runtime configuration. Understanding the full symptom set helps distinguish this issue from similar errors.
Diagnosis in practice
Follow the diagnosis steps in the frontmatter to isolate the cause. Each step includes a command and an interpretation of the output. The goal is to narrow down whether the issue is in the configuration, the runtime, or the application code. Reproduce the error in a minimal setup before applying a fix.
Root cause
The schema sets additionalProperties to false, so any field not in properties is rejected, even if it is valid JSON.
Fix
Remove the extra fields from the input, add them to the schema properties, or set additionalProperties to true or a schema to allow them. After applying the fix, monitor the system to confirm the error does not recur under load or in different environments.
Verification
Validate the corrected input and confirm it passes; verify extra fields are still rejected if additionalProperties remains false. If the verification passes, the fix is confirmed; if not, re-examine the diagnosis steps for missed contributing factors.
Diagnostic commands
Run these commands to reproduce and diagnose the issue:
node -e "console.log(Object.keys(input).filter(k=>!schema.properties[k]))"
grep "additionalProperties" schema.json