# FastAPI请求验证错误：查询参数 'page' 缺失 (类型=值错误.缺失)

- **ID:** `python/fastapi-missing-query-parameter`
- **领域:** python
- **类别:** type_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

请求URL中缺少必需的查询参数。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **Include the query parameter in the request URL.** (95% 成功率)
   ```
   GET /items?page=1
   ```
2. **Make the query parameter optional with a default value.** (90% 成功率)
   ```
   async def read_items(page: int = 1):
   ```

## 无效尝试

- **Adding the parameter to the path instead of query.** — Path parameters and query parameters are different; mixing them causes 404. (70% 失败率)
- **Setting a default value but not making it optional in the function signature.** — If the parameter is required in the function, a default may not be used. (60% 失败率)
