ALL-ROUT0001 · duplicate_route_declaration
Count routes declared more than once for the same method and path.
This is a deterministic rule for all languages. Read its implementation.
Definition
Section titled “Definition”Report a method and path this repository declares in more than one place. Only one of them ever serves a request, and which one depends on registration order rather than on anything a reader can see. The other is dead code that looks live, so an edit to it changes nothing and the next reader spends the afternoon working out why.
Evidence
Section titled “Evidence”Each finding names the method, the path, and every file that declares it. The value is the number of methods and paths declared more than once.
Exceptions
Section titled “Exceptions”A route a mounted router composes a prefix onto is skipped, because its declared path is only part of the path it serves and two routers under different prefixes legitimately declare the same suffix. A framework that dispatches on more than method and path, such as one matching a content type or a host, can carry a real duplicate here.
Examples
Section titled “Examples”@app.get("/users")def list_users(): ...
# admin.py@app.get("/users")def list_users_for_admin(): ...@app.get("/users")def list_users(): ...
@app.get("/admin/users")def list_users_for_admin(): ...References
Section titled “References”- Cites “Express documentation”, the order routes are matched in. Open reference
- Cites “FastAPI documentation”, path operation order. Open reference
- Cites “Patterns of Enterprise Application Architecture”, front controller