# JSON Schema validation fails: additional properties not allowed when schema has 'additionalProperties: false'

- **ID:** `data/json-schema-additional-properties-true`
- **Domain:** data
- **Category:** schema_error
- **Error Code:** `JsonSchemaValidationError`
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

A JSON Schema explicitly sets 'additionalProperties: false' to restrict the object to only defined properties, but the input JSON contains properties not listed in the schema's 'properties' keyword.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| JSON Schema Draft-07+ | active | — | — |
| ajv 8.12+ | active | — | — |
| jsonschema 4.20+ | active | — | — |
| OpenAPI 3.0+ | active | — | — |

## Workarounds

1. **Modify the input JSON to remove the extra properties before validation. For Python: `import json; data = json.loads(input_string); for key in list(data.keys()): if key not in schema['properties']: del data[key];`** (95% success)
   ```
   Modify the input JSON to remove the extra properties before validation. For Python: `import json; data = json.loads(input_string); for key in list(data.keys()): if key not in schema['properties']: del data[key];`
   ```
2. **Use 'unevaluatedProperties: false' instead of 'additionalProperties: false' if using JSON Schema 2019-09 or later. This allows properties defined via $ref or allOf to be evaluated correctly.** (85% success)
   ```
   Use 'unevaluatedProperties: false' instead of 'additionalProperties: false' if using JSON Schema 2019-09 or later. This allows properties defined via $ref or allOf to be evaluated correctly.
   ```
3. **Add the specific extra property to the schema with an appropriate type and description, or use 'additionalProperties' with a type constraint: `"additionalProperties": {"type": "string"}` to allow extra properties but enforce their types.** (80% success)
   ```
   Add the specific extra property to the schema with an appropriate type and description, or use 'additionalProperties' with a type constraint: `"additionalProperties": {"type": "string"}` to allow extra properties but enforce their types.
   ```

## Dead Ends

- **** — This undermines the purpose of strict validation and may allow malicious or malformed data through. (50% fail)
- **** — This is impractical for dynamic or extensible APIs; also, it does not catch typos or unintended properties. (60% fail)
- **** — PatternProperties are evaluated independently of additionalProperties; if both are present, additionalProperties applies to properties not matching any pattern. (40% fail)
