python
config_error
ai_generated
true
ValueError: Duplicate param name 'item_id' in path operation
ID: python/starlette-path-operation-conflict
80%Fix Rate
83%Confidence
0Evidence
2024-08-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Multiple path parameters in a route have the same name, causing ambiguity.
generic中文
路由中的多个路径参数具有相同的名称,导致歧义。
Workarounds
-
95% success Rename one of the path parameters to be unique
@app.route('/items/{item_id}/details/{detail_id}') async def get_detail(item_id: str, detail_id: str): ... -
85% success Combine parameters into a single path segment
@app.route('/items/{item_id}') async def get_item(item_id: str): ...
Dead Ends
Common approaches that don't work:
-
Removing one of the parameters without adjusting the route
80% fail
Breaks the route logic; URL pattern becomes incorrect.
-
Using different variable names but same path segment
90% fail
Starlette still sees duplicate path parameters.