# FastAPI 请求验证错误：查询参数 'page' 缺失

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

## 根因

请求 URL 中未提供必需的查询参数。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   Provide a default value: def read_items(page: int = 1)
   ```
2. **** (90% 成功率)
   ```
   Make it optional with Optional[int] = None and handle None in the function
   ```

## 无效尝试

- **** — If the default is set, FastAPI won't raise an error; the error occurs only when no default is given. (30% 失败率)
- **** — This handles the error but doesn't fix the missing parameter; the client still needs to send it. (60% 失败率)
