Skip to content

Commit ee2f663

Browse files
declan-scaleclaude
andcommitted
test: assert OPTIONS-preflight test matches at least one route
Greptile flagged a vacuous-pass risk: the loop only asserts inside the match branch, so if no route matched the scope the test would pass even on a broken FastAPI version. Count matches and assert matched > 0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent ec28335 commit ee2f663

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

agentex/tests/unit/api/test_otel_route_compat.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,14 @@ def test_options_preflight_route_matching_does_not_crash(self):
4949
"path": "/agents",
5050
"headers": [],
5151
}
52+
matched = 0
5253
for route in fastapi_app.routes:
5354
match, _ = route.matches(scope)
5455
if match in (Match.FULL, Match.PARTIAL):
56+
matched += 1
5557
assert route.path is not None
58+
assert matched > 0, (
59+
"No route matched the OPTIONS /agents preflight scope, so the "
60+
"`.path` assertion never ran. The test would pass vacuously even "
61+
"on a broken FastAPI version. Pick a path served by app.routes."
62+
)

0 commit comments

Comments
 (0)