{
  "id": "python/fastapi-http-exception-not-json",
  "signature": "TypeError: Object of type HTTPException is not JSON serializable",
  "signature_zh": "TypeError: HTTPException 类型的对象无法进行 JSON 序列化",
  "regex": "TypeError:\\ Object\\ of\\ type\\ HTTPException\\ is\\ not\\ JSON\\ serializable",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "A route returned an HTTPException instance instead of raising it, so FastAPI tried to serialize the exception object as the response body.",
  "root_cause_type": "generic",
  "root_cause_zh": "路由返回了 HTTPException 实例而不是抛出它，导致 FastAPI 尝试将异常对象序列化为响应正文。",
  "versions": [
    {
      "version": "0.100+",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Returns a 200 with exception internals in the body instead of an error status.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Leaks stack/details and still uses the wrong status code.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.98,
      "how": "raise HTTPException(status_code=404, detail='Not found')",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "from fastapi.responses import JSONResponse\nreturn JSONResponse(status_code=404, content={'detail': 'Not found'})",
      "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-05-04",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}