{
  "id": "python/starlette-http-exception-not-found",
  "signature": "starlette.exceptions.HTTPException: 404 Not Found",
  "signature_zh": "Starlette HTTP 异常：404 未找到。",
  "regex": "starlette\\.exceptions\\.HTTPException:\\ 404\\ Not\\ Found",
  "domain": "python",
  "category": "network_error",
  "subcategory": null,
  "root_cause": "Requested URL does not match any route in the Starlette application.",
  "root_cause_type": "generic",
  "root_cause_zh": "请求的 URL 与 Starlette 应用中的任何路由不匹配。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Catch-all routes may shadow specific routes if defined first.",
      "fail_rate": 0.75,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Middleware cannot easily modify response status; may cause recursion.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "from starlette.applications import Starlette\nfrom starlette.routing import Route\n\nasync def homepage(request):\n    return Response('Hello')\n\nroutes = [Route('/', homepage)]\napp = Starlette(routes=routes)\n# Ensure route paths are correct with trailing slashes",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.85,
      "how": "Add a custom 404 handler: \nfrom starlette.exceptions import HTTPException\nfrom starlette.responses import JSONResponse\n\nasync def not_found(request, exc):\n    return JSONResponse(status_code=404, content={\"message\": \"Not Found\"})\n\napp.add_exception_handler(HTTPException, 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.82,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-10",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}