{
  "id": "python/starlette-route-parameter-type-mismatch",
  "signature": "TypeError: 'str' object cannot be interpreted as an integer",
  "signature_zh": "类型错误：'str'对象无法解释为整数",
  "regex": "TypeError:\\ 'str'\\ object\\ cannot\\ be\\ interpreted\\ as\\ an\\ integer",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "A route parameter expected as an integer is passed as a string without conversion.",
  "root_cause_type": "generic",
  "root_cause_zh": "预期为整数的路由参数以字符串形式传递，未进行转换。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Using str() on the parameter",
      "why_fails": "Doesn't convert to int; keeps it as string.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "Ignoring the type and using the string directly",
      "why_fails": "May cause errors in logic expecting an integer.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Convert the parameter to int explicitly",
      "success_rate": 0.9,
      "how": "async def get_item(item_id: str):\n    item_id = int(item_id)",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use Starlette's path converter for int",
      "success_rate": 0.95,
      "how": "@app.route('/items/{item_id:int}')\nasync def get_item(item_id: int):\n    ...",
      "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-10-01",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}