{
  "id": "python/starlette-runtimeerror-no-route-match",
  "signature": "RuntimeError: No route matches for path '/api/items/123'",
  "signature_zh": "RuntimeError: 没有匹配路径 '/api/items/123' 的路由",
  "regex": "RuntimeError:\\ No\\ route\\ matches\\ for\\ path\\ '/api/items/123'",
  "domain": "python",
  "category": "runtime_error",
  "subcategory": null,
  "root_cause": "The requested URL path does not match any defined 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": "Adding a catch-all route without proper order.",
      "why_fails": "Catch-all routes must be defined last; otherwise they override specific routes.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "Using regular expression in route path incorrectly.",
      "why_fails": "Starlette uses path parameters with curly braces, not regex. Misuse leads to no match.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Define a route with path parameter.",
      "success_rate": 0.95,
      "how": "from starlette.applications import Starlette\nfrom starlette.responses import JSONResponse\napp = Starlette()\n@app.route('/api/items/{item_id}')\nasync def get_item(request):\n    return JSONResponse({'id': request.path_params['item_id']})",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a 404 handler for unmatched routes.",
      "success_rate": 0.9,
      "how": "from starlette.responses import PlainTextResponse\n@app.exception_handler(404)\nasync def not_found(request, exc):\n    return PlainTextResponse('Not Found', status_code=404)",
      "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-05-20",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}