python
config_error
ai_generated
true
AssertionError: Route order matters, overlapping routes detected
ID: python/starlette-route-order-shadowing
80%Fix Rate
82%Confidence
0Evidence
2024-07-28First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 3.x | active | — | — | — |
Root Cause
Defining a catch-all or parameterized route before a specific route causes shadowing.
generic中文
在特定路由之前定义了通配符或参数化路由,导致遮蔽。
Workarounds
-
95% success
Define specific routes first: routes = [ Route('/users/me', me), Route('/users/{user_id}', user), ] -
90% success
Use path converters with constraints: Route('/files/{path:path}', file_handler)
Dead Ends
Common approaches that don't work:
-
50% fail
Loses functionality; should reorder instead.
-
60% fail
Regex may still match broader patterns.