{
  "id": "python/pydantic-extra-forbidden",
  "signature": "pydantic_core._pydantic_core.ValidationError: 2 validation errors for User\nfoo\n  Extra inputs are not permitted [type=extra_forbidden, input_value='bar', input_type=str]",
  "signature_zh": "pydantic_core._pydantic_core.ValidationError：User 出现 2 个验证错误\nfoo\n  不允许额外输入 [type=extra_forbidden, input_value='bar', input_type=str]",
  "regex": "pydantic_core\\._pydantic_core\\.ValidationError:\\ 2\\ validation\\ errors\\ for\\ User\\\nfoo\\\n\\ \\ Extra\\ inputs\\ are\\ not\\ permitted\\ \\[type=extra_forbidden,\\ input_value='bar',\\ input_type=str\\]",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "model_config has extra='forbid'. The incoming dict contains keys not declared on the model.",
  "root_cause_type": "generic",
  "root_cause_zh": "model_config 设置了 extra='forbid'。传入的字典包含模型未声明的键。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Silently drops fields users expect to be persisted, causing data loss bugs.",
      "fail_rate": 0.55,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Hides schema drift; clients keep sending wrong fields and you never notice.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Pydantic v2 does not accept **kwargs in BaseModel subclasses; raises PydanticUserError.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "class User(BaseModel):\n    model_config = ConfigDict(extra='forbid')\n    foo: str | None = None",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "class User(BaseModel):\n    model_config = ConfigDict(extra='allow')",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": null,
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-02-27",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}