{
  "id": "python/fastapi-path-param-type-mismatch",
  "signature": "TypeError: '<=' not supported between instances of 'str' and 'int'",
  "signature_zh": "类型错误: 'str' 和 'int' 实例之间不支持 '<='",
  "regex": "TypeError:\\ '<='\\ not\\ supported\\ between\\ instances\\ of\\ 'str'\\ and\\ 'int'",
  "domain": "python",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "FastAPI路径参数声明为int但实际传入字符串，且在比较操作中未转换。",
  "root_cause_type": "generic",
  "root_cause_zh": "FastAPI路径参数声明为int但实际传入字符串，且在比较操作中未转换。",
  "versions": [
    {
      "version": "3.x",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "在路由函数内部添加类型检查并手动转换",
      "why_fails": "代码冗余且容易遗漏。",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "使用str类型接受参数再转换",
      "why_fails": "失去类型验证优势。",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "确保FastAPI路径参数类型注解正确，框架自动转换",
      "success_rate": 0.98,
      "how": "from fastapi import FastAPI; app = FastAPI(); @app.get('/items/{item_id}') async def read_item(item_id: int): return {'item_id': item_id}",
      "condition": "",
      "sources": []
    },
    {
      "action": "使用Path参数验证器确保类型",
      "success_rate": 0.95,
      "how": "from fastapi import Path; @app.get('/items/{item_id}') async def read_item(item_id: int = Path(..., ge=1)): return {'item_id': item_id}",
      "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.87,
  "fix_success_rate": 0.8,
  "resolvable": "true",
  "first_seen": "2024-05-12",
  "last_confirmed": "2025-01-01",
  "last_updated": "2025-01-01",
  "evidence_count": 0,
  "tags": [],
  "locale": "en",
  "aliases": []
}