# werkzeug.exceptions.BadRequestKeyError: 400 Bad Request: KeyError: 'id'

- **ID:** `python/flask-route-param-type-error`
- **Domain:** python
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

在路由或请求中尝试访问不存在的参数 `id`。

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   使用 `request.args.get('id')` 并检查是否为 None。
   ```
2. **** (90% success)
   ```
   在路由参数中声明 `@app.route('/<int:id>')` 确保参数存在。
   ```

## Dead Ends

- **** — 尝试使用 `request.args['id']` 但未捕获 KeyError，导致错误。 (70% fail)
- **** — 尝试在模板中使用 `request.args.get('id')` 但未处理 None。 (60% fail)
