{
  "id": "data/json-schema-additional-properties-true",
  "signature": "JSON Schema validation fails: additional properties not allowed when schema has 'additionalProperties: false'",
  "signature_zh": "JSON Schema验证失败：模式具有'additionalProperties: false'时不允许额外属性",
  "regex": "additional properties not allowed|additionalProperties must be false",
  "domain": "data",
  "category": "schema_error",
  "subcategory": null,
  "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.",
  "root_cause_type": "generic",
  "root_cause_zh": "JSON Schema显式设置'additionalProperties: false'以将对象限制为仅定义的属性，但输入JSON包含模式'properties'关键字中未列出的属性。",
  "versions": [
    {
      "version": "JSON Schema Draft-07+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ajv 8.12+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "jsonschema 4.20+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "OpenAPI 3.0+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This undermines the purpose of strict validation and may allow malicious or malformed data through.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This is impractical for dynamic or extensible APIs; also, it does not catch typos or unintended properties.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "PatternProperties are evaluated independently of additionalProperties; if both are present, additionalProperties applies to properties not matching any pattern.",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "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];`",
      "success_rate": 0.95,
      "how": "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];`",
      "condition": "",
      "sources": []
    },
    {
      "action": "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.",
      "success_rate": 0.85,
      "how": "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.",
      "condition": "",
      "sources": []
    },
    {
      "action": "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.",
      "success_rate": 0.8,
      "how": "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.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在验证之前修改输入JSON以删除多余属性。对于Python：`import json; data = json.loads(input_string); for key in list(data.keys()): if key not in schema['properties']: del data[key];`",
    "如果使用JSON Schema 2019-09或更高版本，使用'unevaluatedProperties: false'代替'additionalProperties: false'。这允许通过$ref或allOf定义的属性被正确评估。",
    "将特定的额外属性添加到模式中，附带适当的类型和描述，或使用带类型约束的'additionalProperties'：`\"additionalProperties\": {\"type\": \"string\"}` 以允许额外属性但强制其类型。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://json-schema.org/understanding-json-schema/reference/object.html#additional-properties",
  "official_doc_section": null,
  "error_code": "JsonSchemaValidationError",
  "verification_tier": "ai_generated",
  "confidence": 0.92,
  "fix_success_rate": 0.9,
  "resolvable": "true",
  "first_seen": "2023-09-18",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}