You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
hosting: http_exception_handler drops HTTPException.headers, so a route cannot set Vary, Cache-Control or WWW-Authenticate on an error response #369
The host's HTTPException handler rebuilds the response from status_code and detail only. Any headers a route attached to the exception are discarded. Starlette and FastAPI both honour HTTPException(headers=...) by default; the host's override silently loses them.
curl -i http://localhost:8000/api/<module>/x
HTTP/1.1 404 Not Found
content-type: application/json
... # neither Cache-Control nor Vary is present
Why it matters
A public, cacheable read API on a multi-tenant host has to mark its 404s Cache-Control: no-store and Vary: <tenant header>, otherwise a shared cache keyed on the URL serves one tenant's 404 for another tenant's existing record. The same mechanism is how 401 carries WWW-Authenticate and 429 carries Retry-After. None of those can be set through the exception today.
Workaround in the records module
antosubash/smpy_modules#37 installs a custom APIRoute class (PublicErrorRoute) on its public router that catches HTTPException before the host handler and renders the JSON body itself so the headers survive. Every module wanting a header on an error response has to repeat that.
Already fixed by #274 (v0.0.33): http_exception_handler in framework/hosting/simple_module_hosting/_error_handlers.py passes exc.headers to both the JSON response and render_error_page; covered by framework/hosting/tests/test_error_status_coverage.py (WWW-Authenticate / Retry-After cases).
Activity
antosubash commentedon Oct 1, 2026
Already fixed by #274 (v0.0.33):
http_exception_handlerinframework/hosting/simple_module_hosting/_error_handlers.pypassesexc.headersto both the JSON response andrender_error_page; covered byframework/hosting/tests/test_error_status_coverage.py(WWW-Authenticate / Retry-After cases).