{
  "id": "python/starlette-route-parameter-type-conversion",
  "signature": "TypeError: Path parameter 'id' must be an integer",
  "signature_zh": "类型错误：路径参数'id'必须是整数",
  "regex": "TypeError:\\ Path\\ parameter\\ 'id'\\ must\\ be\\ an\\ integer",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Starlette路由参数类型转换失败，预期整数但收到其他类型",
  "root_cause_type": "generic",
  "root_cause_zh": "Starlette路由参数类型转换失败，预期整数但收到其他类型",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "在路由处理函数中手动转换类型",
      "why_fails": "Starlette在调用函数前已尝试转换，失败会抛出异常",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    },
    {
      "action": "使用字符串类型参数忽略转换",
      "why_fails": "类型转换是路由定义的一部分，忽略可能导致逻辑错误",
      "fail_rate": 0.4,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "确保URL路径包含有效整数",
      "success_rate": 0.95,
      "how": "GET /items/123",
      "condition": "",
      "sources": []
    },
    {
      "action": "在路由定义中使用字符串类型并手动验证",
      "success_rate": 0.9,
      "how": "from starlette.routing import Route\nasync def endpoint(request):\n    id = request.path_params['id']\n    if not id.isdigit():\n        return JSONResponse({'error': 'Invalid ID'}, status_code=400)",
      "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.84,
  "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": []
}