# TypeError: Path parameter 'id' must be an integer

- **ID:** `python/starlette-route-parameter-type-conversion`
- **Domain:** python
- **Category:** type_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Starlette路由参数类型转换失败，预期整数但收到其他类型

## Version Compatibility

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

## Workarounds

1. **确保URL路径包含有效整数** (95% success)
   ```
   GET /items/123
   ```
2. **在路由定义中使用字符串类型并手动验证** (90% success)
   ```
   from starlette.routing import Route
async def endpoint(request):
    id = request.path_params['id']
    if not id.isdigit():
        return JSONResponse({'error': 'Invalid ID'}, status_code=400)
   ```

## Dead Ends

- **在路由处理函数中手动转换类型** — Starlette在调用函数前已尝试转换，失败会抛出异常 (50% fail)
- **使用字符串类型参数忽略转换** — 类型转换是路由定义的一部分，忽略可能导致逻辑错误 (40% fail)
