{
  "id": "python/pydantic-v2-model-fields-deprecated",
  "signature": "PydanticDeprecatedSince20: `__fields__` is deprecated; use `model_fields` instead. Deprecated in Pydantic V2.0 to be removed in V3.0.",
  "signature_zh": "PydanticDeprecatedSince20: `__fields__` 已弃用，请改用 `model_fields`",
  "regex": "PydanticDeprecatedSince20:\\ `__fields__`\\ is\\ deprecated;\\ use\\ `model_fields`\\ instead\\.\\ Deprecated\\ in\\ Pydantic\\ V2\\.0\\ to\\ be\\ removed\\ in\\ V3\\.0\\.",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "Code written for Pydantic v1 accesses model.__fields__ or .dict()/.json() which are deprecated in v2 in favor of model_fields, model_dump(), model_dump_json().",
  "root_cause_type": "generic",
  "root_cause_zh": "为 Pydantic v1 编写的代码访问 model.__fields__ 或 .dict()/.json()，这些在 v2 中已弃用，应改用 model_fields、model_dump()、model_dump_json()。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Hides the deprecation but the code still breaks when upgrading to v3 or when stderr is treated as failure in CI.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Conflicts with libraries (FastAPI 0.100+, LangChain) that require v2, causing install errors.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Replace attribute access:\n\n# v1\nfor name, field in User.__fields__.items(): ...\n# v2\nfor name, field in User.model_fields.items(): ...",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Replace serialization methods:\n\nobj.dict()      -> obj.model_dump()\nobj.json()      -> obj.model_dump_json()\nobj.parse_obj(d) -> obj.model_validate(d)",
      "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.86,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-01-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}