# 断言错误：路径/items与现有路由冲突。

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

## 根因

在Starlette应用中定义了多个相同路径的路由，导致冲突。

## 版本兼容性

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

## 解决方案

1. **** (95% 成功率)
   ```
   合并路由或使用不同路径：
@app.route("/items")
async def list_items(request): ...
@app.route("/items/{item_id}")
async def get_item(request): ...
   ```
2. **** (90% 成功率)
   ```
   使用路由前缀：
app = Starlette(routes=[
    Route("/api/items", endpoint=...),
    Route("/api/items/{id}", endpoint=...)
])
   ```

## 无效尝试

- **** — 尝试使用不同的方法（GET/POST）但路径相同，仍会冲突。 (60% 失败率)
- **** — 忽略冲突，但路由匹配可能意外。 (80% 失败率)
