# fastapi.routing.APIRoute: Route order conflict: /items/{item_id} conflicts with /items/new

- **ID:** `python/fastapi-route-order-conflict`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

FastAPI 中动态路由和静态路由顺序不当，导致动态路由捕获了静态路径。

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   @app.get('/items/new')
async def new_item(): ...
@app.get('/items/{item_id}')
async def get_item(item_id: int): ...
   ```
2. **** (90% success)
   ```
   @app.get('/items/{item_id:\\d+}')
async def get_item(item_id: int): ...
   ```

## Dead Ends

- **** — 如果业务需要这两个路径，忽略会导致功能缺失。 (50% fail)
- **** — FastAPI 按定义顺序匹配，交换后可能仍冲突。 (60% fail)
