[Arch] No centralized exception handler; ad hoc try/except per route #53

Closed
opened 2026-07-01 07:26:35 +02:00 by bullitt · 1 comment
Owner

Severity: Low | Category: Backend

Zero @app.exception_handler registrations; 16 try/13 except blocks and 52 HTTPException raises scattered across main.py, including broad except Exception at main.py:606-609 and 1319-1320.

Recommendation: Add one @app.exception_handler(Exception) for a consistent last-resort 500 shape + log line.

Full detail: docs/architecture-review.md § C, Finding "No centralized exception handler..."

**Severity:** Low | **Category:** Backend Zero `@app.exception_handler` registrations; 16 try/13 except blocks and 52 `HTTPException` raises scattered across main.py, including broad `except Exception` at main.py:606-609 and 1319-1320. **Recommendation:** Add one `@app.exception_handler(Exception)` for a consistent last-resort 500 shape + log line. Full detail: `docs/architecture-review.md` § C, Finding "No centralized exception handler..."
Author
Owner

Fixed on branch architecture-rework, commit d95358f: added @app.exception_handler(Exception) returning the documented {"detail": "Internal server error"} shape, logging the full exception server-side without leaking it to the client. Confirmed Starlette's ServerErrorMiddleware still re-raises after generating the response, so TestClient(raise_server_exceptions=True) still surfaces real bugs during tests — no loss of test signal. Added test_unhandled_exception_returns_generic_500. Full suite: 258 passed.

Fixed on branch `architecture-rework`, commit d95358f: added `@app.exception_handler(Exception)` returning the documented `{"detail": "Internal server error"}` shape, logging the full exception server-side without leaking it to the client. Confirmed Starlette's `ServerErrorMiddleware` still re-raises after generating the response, so `TestClient(raise_server_exceptions=True)` still surfaces real bugs during tests — no loss of test signal. Added `test_unhandled_exception_returns_generic_500`. Full suite: 258 passed.
Sign in to join this conversation.
No labels
arch
harness
security
ux
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bullitt/trackbox#53
No description provided.