{
  "id": "python/pydantic-model-frozen-mutation",
  "signature": "pydantic_core._pydantic_core.ValidationError: 1 validation error for Config\n__root__\n  Instance is frozen [type=frozen_instance, input_value=Config(x=1), input_type=Config]",
  "signature_zh": "pydantic_core._pydantic_core.ValidationError：1 个验证错误（Config）\n__root__\n  实例已冻结 [type=frozen_instance, input_value=Config(x=1), input_type=Config]",
  "regex": "pydantic_core\\._pydantic_core\\.ValidationError:\\ 1\\ validation\\ error\\ for\\ Config\\\n__root__\\\n\\ \\ Instance\\ is\\ frozen\\ \\[type=frozen_instance,\\ input_value=Config\\(x=1\\),\\ input_type=Config\\]",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The model was declared with model_config = ConfigDict(frozen=True) and code attempted to mutate an attribute after construction.",
  "root_cause_type": "generic",
  "root_cause_zh": "模型声明为 model_config = ConfigDict(frozen=True)，但构造后代码尝试修改其属性。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "There is no override; frozen is enforced via pydantic-core in Rust.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Bypasses validation and hash consistency, breaking dict/set usage of the model.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "model_config is class-level; mutating it affects all instances and is not thread-safe.",
      "fail_rate": 0.45,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "c2 = c.model_copy(update={'x': 2})\nassert c2.x == 2 and c.x == 1",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "from pydantic import BaseModel, ConfigDict\nclass Config(BaseModel):\n    model_config = ConfigDict(frozen=False)\n    x: int",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-06-18",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}