{
  "id": "python/pydantic-config-error-json-schema-extra",
  "signature": "pydantic.errors.PydanticUserError: `model_config` cannot be used as a model field name. Use `model_config` for model configuration.",
  "signature_zh": "pydantic.errors.PydanticUserError: `model_config` 不能用作模型字段名。请使用 `model_config` 作为模型配置。",
  "regex": "pydantic\\.errors\\.PydanticUserError:\\ `model_config`\\ cannot\\ be\\ used\\ as\\ a\\ model\\ field\\ name\\.\\ Use\\ `model_config`\\ for\\ model\\ configuration\\.",
  "domain": "python",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "A v2 model defines an attribute literally named `model_config` (often ported from v1 code where the field was user-defined), which Pydantic reserves for configuration.",
  "root_cause_type": "generic",
  "root_cause_zh": "v2 模型中定义了名为 `model_config` 的属性（通常从 v1 代码移植而来），而 Pydantic 保留该名称用于配置。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Renaming only in the class but not in callers leaves `AttributeError` at runtime when code reads `obj.model_config`.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Adding `class Config` alongside `model_config` triggers a second PydanticUserError about mixing v1 and v2 config styles.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Rename the field and add an alias: `class M(BaseModel):\n    model_config = ConfigDict(populate_by_name=True)\n    cfg: dict = Field(alias='model_config')`",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Use `Field(alias='model_config')` and read via `obj.cfg`; update all callers to use the new attribute name.",
      "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-04-02",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}