diff --git a/fastapi/routing.py b/fastapi/routing.py index fa1351859..8842745bd 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -1204,6 +1204,7 @@ class APIRouter(routing.Router): app.include_router(internal_router) ``` """ + assert self != router, "Router cannot be the same as parent" if prefix: assert prefix.startswith("/"), "A path prefix must start with '/'" assert not prefix.endswith(