{
  "id": "python/starlette-route-param-type-error",
  "signature": "ValueError: Invalid value for path parameter 'id'. Expected int, got 'abc'",
  "signature_zh": "值错误：路径参数 'id' 的值无效。期望整数，但得到 'abc'。",
  "regex": "ValueError:\\ Invalid\\ value\\ for\\ path\\ parameter\\ 'id'\\.\\ Expected\\ int,\\ got\\ 'abc'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "在 Starlette 路由中定义了路径参数类型为 int，但客户端传入了非数字字符串。",
  "root_cause_type": "generic",
  "root_cause_zh": "在 Starlette 路由中定义了路径参数类型为 int，但客户端传入了非数字字符串。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "如果参数是 URL 路径的一部分，无法在客户端转换。",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "改变了 API 设计，可能影响其他依赖该参数类型的代码。",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "",
      "success_rate": 0.9,
      "how": "from starlette.routing import Route\nasync def get_item(request):\n    id = request.path_params['id']\n    try:\n        id = int(id)\n    except ValueError:\n        return JSONResponse({'error': 'invalid'}, status_code=400)",
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "success_rate": 0.95,
      "how": "Route('/items/{id:int}', get_item)",
      "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.85,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-07-19",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}