From 4c9cf7439f8e769af600c87190a44367583526cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20S=C3=A1nchez=20Castro?= <72013291+JavierSanchezCastro@users.noreply.github.com> Date: Thu, 30 Oct 2025 13:06:06 +0100 Subject: [PATCH] Update fastapi/routing.py Co-authored-by: Motov Yurii <109919500+YuriiMotov@users.noreply.github.com> --- fastapi/routing.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fastapi/routing.py b/fastapi/routing.py index eb3d2c620..a6ed2f328 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -1333,7 +1333,10 @@ class APIRouter(routing.Router): app.include_router(internal_router) ``` """ - assert self is not router, "Cannot include router into itself" + assert self is not router, ( + "Cannot include the same APIRouter instance into itself. " + "Did you mean to include a different router?" + ) if prefix: assert prefix.startswith("/"), "A path prefix must start with '/'" assert not prefix.endswith("/"), (