{
  "id": "python/pydantic-json-schema-generation-error",
  "signature": "pydantic.errors.PydanticInvalidForJsonSchema: Cannot generate a JsonSchema for core_schema.IsInstanceSchema (<class 'decimal.Decimal'>)",
  "signature_zh": "pydantic.errors.PydanticInvalidForJsonSchema: 无法为核心模式 IsInstanceSchema (<class 'decimal.Decimal'>) 生成 JsonSchema",
  "regex": "pydantic\\.errors\\.PydanticInvalidForJsonSchema:\\ Cannot\\ generate\\ a\\ JsonSchema\\ for\\ core_schema\\.IsInstanceSchema\\ \\(<class\\ 'decimal\\.Decimal'>\\)",
  "domain": "python",
  "category": "data_error",
  "subcategory": null,
  "root_cause": "A field uses an arbitrary Python type (via arbitrary_types_allowed or a custom class) that has no defined JSON Schema representation, so model_json_schema() fails.",
  "root_cause_type": "generic",
  "root_cause_zh": "字段使用了没有定义 JSON Schema 表示的任意 Python 类型（通过 arbitrary_types_allowed 或自定义类），导致 model_json_schema() 失败。",
  "versions": [
    {
      "version": "2.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Returns an empty schema, breaking OpenAPI docs and client generation downstream.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This allows the type at validation time but does not teach Pydantic how to serialize it to JSON Schema.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "from typing import Annotated\nfrom pydantic import BaseModel, WithJsonSchema\n\nclass Model(BaseModel):\n    amount: Annotated[Decimal, WithJsonSchema({'type': 'string', 'format': 'decimal'})]",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.88,
      "how": "class Model(BaseModel):\n    amount: float  # or str; convert to Decimal in business logic",
      "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-06-21",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}