{
  "id": "python/fastapi-json-encoding-error",
  "signature": "TypeError: Object of type UUID is not JSON serializable",
  "signature_zh": "TypeError: 类型为 UUID 的对象无法 JSON 序列化",
  "regex": "TypeError:\\ Object\\ of\\ type\\ UUID\\ is\\ not\\ JSON\\ serializable",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "FastAPI's default JSON encoder cannot handle UUID objects in the response.",
  "root_cause_type": "generic",
  "root_cause_zh": "FastAPI 的默认 JSON 编码器无法处理响应中的 UUID 对象。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This is repetitive and error-prone if missed in some places.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "If imported incorrectly, it may not convert UUIDs.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Use jsonable_encoder: from fastapi.encoders import jsonable_encoder; return jsonable_encoder(data)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Define a custom response class that handles UUIDs: class UUIDModel(BaseModel): id: UUID",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-09-05",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}