# TypeError: '<=' not supported between instances of 'str' and 'int'

- **ID:** `python/fastapi-path-param-type-mismatch`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

FastAPI路径参数声明为int但实际传入字符串，且在比较操作中未转换。

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **确保FastAPI路径参数类型注解正确，框架自动转换** (98% success)
   ```
   from fastapi import FastAPI; app = FastAPI(); @app.get('/items/{item_id}') async def read_item(item_id: int): return {'item_id': item_id}
   ```
2. **使用Path参数验证器确保类型** (95% success)
   ```
   from fastapi import Path; @app.get('/items/{item_id}') async def read_item(item_id: int = Path(..., ge=1)): return {'item_id': item_id}
   ```

## Dead Ends

- **在路由函数内部添加类型检查并手动转换** — 代码冗余且容易遗漏。 (60% fail)
- **使用str类型接受参数再转换** — 失去类型验证优势。 (50% fail)
