Skip to content

Commit cd243d1

Browse files
fix(ci): Backend CI was red because FastAPI 0.141 stopped listing routes
Found it. From FastAPI 0.141 an included router appears in app.routes as a single path-less _IncludedRouter. Walking app.routes therefore finds no /api/v1 route at all while every request still returns 200. requirements.txt does not pin fastapi, so CI installs 0.141.1 and this laptop has 0.135.1 - which is why the old inline route check failed on every CI run since at least 8 September and passed locally, and why its replacement failed the same way. Reproduced with a minimal app on both versions. The route test now reads the OpenAPI schema, which is public and version-stable. Full suite: 86 passed on 0.135.1 and 86 passed on 0.141.1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent ea1b258 commit cd243d1

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎backend/tests/test_api.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ def test_unknown_project_is_404(client):
8282

8383
# The route contract the old inline CI script checked, as a test that says what
8484
# is missing instead of exiting 1 with no output.
85+
#
86+
# Read from the OpenAPI schema, NOT app.routes. From FastAPI 0.141 an included
87+
# router shows up in app.routes as one path-less _IncludedRouter, so walking
88+
# app.routes finds no /api/v1 route at all while every request still works -
89+
# which is exactly why the inline check failed on CI (unpinned, 0.141) and
90+
# passed locally (0.135) for a week.
8591
REQUIRED_ROUTES = [
8692
"/api/v1/tools", "/api/v1/tools/{slug}", "/api/v1/tools/{slug}/resources",
8793
"/api/v1/projects", "/api/v1/projects/{slug}", "/api/v1/roadmaps",
@@ -90,6 +96,6 @@ def test_unknown_project_is_404(client):
9096

9197

9298
def test_public_routes_are_registered():
93-
registered = {getattr(r, "path", None) for r in app.routes}
99+
registered = set(app.openapi()["paths"])
94100
missing = [p for p in REQUIRED_ROUTES if p not in registered]
95101
assert not missing, f"routes not registered: {missing}"

0 commit comments

Comments
 (0)