{
  "id": "python/pydantic-arbitrary-types-not-allowed",
  "signature": "pydantic.errors.PydanticSchemaGenerationError: Unable to generate pydantic-core schema for <class 'decimal.Decimal'>. Set `arbitrary_types_allowed=True` in the model_config to ignore this error or implement `__get_pydantic_core_schema__` on your type to fully support it.",
  "signature_zh": "pydantic.errors.PydanticSchemaGenerationError: 无法为 <class 'decimal.Decimal'> 生成 pydantic-core schema。请在 model_config 中设置 `arbitrary_types_allowed=True` 以忽略此错误，或实现 `__get_pydantic_core_schema__`。",
  "regex": "pydantic\\.errors\\.PydanticSchemaGenerationError:\\ Unable\\ to\\ generate\\ pydantic\\-core\\ schema\\ for\\ <class\\ 'decimal\\.Decimal'>\\.\\ Set\\ `arbitrary_types_allowed=True`\\ in\\ the\\ model_config\\ to\\ ignore\\ this\\ error\\ or\\ implement\\ `__get_pydantic_core_schema__`\\ on\\ your\\ type\\ to\\ fully\\ support\\ it\\.",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "A field uses a class Pydantic cannot introspect (a custom class or third-party type lacking a schema hook), and `arbitrary_types_allowed` is not enabled.",
  "root_cause_type": "generic",
  "root_cause_zh": "字段使用了 Pydantic 无法内省的类型（自定义类或缺少 schema 钩子的第三方类型），且未启用 `arbitrary_types_allowed`。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Adding `arbitrary_types_allowed=True` without `isinstance` checks means the field is never validated, leading to silent bad data.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Subclassing the third-party type does not help; Pydantic still cannot introspect it.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Enable it: `model_config = ConfigDict(arbitrary_types_allowed=True)` and add a `field_validator` for the type.",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Implement `__get_pydantic_core_schema__` on the custom class to provide a proper schema.",
      "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-06-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}