{
  "id": "python/starlette-http-exception-status-code",
  "signature": "starlette.exceptions.HTTPException: 404: Not Found",
  "signature_zh": "starlette.exceptions.HTTPException: 404：未找到。",
  "regex": "starlette\\.exceptions\\.HTTPException:\\ 404:\\ Not\\ Found",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "A route or dependency explicitly raised HTTPException(404) or a router matched no path, and the exception was not handled by a custom handler.",
  "root_cause_type": "generic",
  "root_cause_zh": "某个路由或依赖显式抛出了 HTTPException(404)，或路由器未匹配到任何路径，且异常未被自定义处理器捕获。",
  "versions": [
    {
      "version": "0.37.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "0.40.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "HTTPException is handled by Starlette's HTTPException handler before generic Exception; order matters and generic handler may not fire.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Duplicates logic across every route and bypasses OpenAPI error docs.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.95,
      "how": "@app.exception_handler(HTTPException)\nasync def handler(request, exc):\n    return JSONResponse({'detail': exc.detail}, status_code=exc.status_code)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.9,
      "how": "Register the handler on the specific router or app instance used in tests, not on a different app object.",
      "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-07-21",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}