0.137.0: empty-path route nested under prefix-less outer include raises 'Prefix and path cannot be both empty' #15750
-
First Check
Commit to Help
Example Codefrom fastapi import FastAPI, APIRouter
leaf = APIRouter()
@leaf.get("") # empty path
def list_items():
return []
inner = APIRouter()
inner.include_router(leaf, prefix="/items") # inner include HAS a prefix
app = FastAPI()
app.include_router(inner) # outer include has NO prefixDescriptionOn 0.137.0, the last line raises at app-construction time: On 0.136.3 and earlier the same code works and registers the route at This is a regression introduced by the route-tree refactor in #15745 (preserving It only happens when an empty-path route (
Operating SystemmacOS Operating System DetailsNo response FastAPI Version0.137.0 Pydantic Version2.13.4 Python Version3.12.13 Additional ContextRoot-cause pointer (from a quick read of 0.137.0 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Thanks for the report, we'll look into this! |
Beta Was this translation helpful? Give feedback.
This should be fixed in #15763 , available in FastAPI 0.137.1, just released. 🚀