# FastAPI错误：函数中参数名重复

- **ID:** `python/fastapi-route-order-matters`
- **领域:** python
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在特定路由之后定义通配路由（如`@app.get('/{path}')`）可能导致FastAPI错误解释路径参数，引发重复参数错误或错误匹配。

## 版本兼容性

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

## 解决方案

1. **** (90% 成功率)
   ```
   Define specific routes before catch-all routes, and ensure catch-all uses a distinct parameter name like `{path:path}` with a converter.
   ```
2. **** (85% 成功率)
   ```
   Use `@app.api_route('/{path}', methods=['GET'], include_in_schema=False)` for catch-all to avoid conflicts.
   ```

## 无效尝试

- **** — Reordering routes doesn't fix the duplicate parameter error if the catch-all is too broad. (80% 失败率)
- **** — Using a different parameter name in the catch-all still conflicts with other routes. (75% 失败率)
