Files
romm/backend/tools
Georges-Antoine Assi ca8efb7a11 test(api): check returned, forwarded and stale error statuses (#5715)
* test(api): check returned and forwarded error statuses too

The route error check only saw HTTPException with a literal status. It
now also counts error responses a route returns, statuses passed to a
helper, status maps, IfExp and local variables. A status it still cannot
read fails the check instead of passing silently. Routes left out of the
schema are skipped, and 422 counts as documented only when FastAPI
documents it. The API description now names the middleware errors no
route lists.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* test(api): fail on documented statuses a route cannot raise

Add a stale check, the reverse of the undocumented one. To keep its
false positives near zero, the analyzer now follows functions run
through asyncio.to_thread and similar offloads, and skips a try body
whose handler swallows every error (keeping the responses it returns).
A new `# route-errors: raises <codes>` marker declares what a line
raises when the analyzer cannot follow or read it.

Following offloads found an undocumented 502 on save-and-exit: a
container with no broker address fails the card wipe. search_cover
declares the SteamGridDB 401 it re-raises from a gather.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* pr-ready: code-review

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* pr-ready: simplify

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* pr-ready: review-polish

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* pr-ready: plain-prose

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* pr-ready: code-review (best-effort broker PUT never raises)

put_binary_json looked up the broker URL outside its try, so a container
with no broker address raised a 502 from a helper documented as never
raising. Evacuation already fails first on that container, so the 502
documented on save-and-exit could not happen; drop it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* pr-ready: plain-prose (code-review additions)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* pr-ready: review-polish (build a real container in the broker test)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-21 16:37:42 -05:00
..