INNER CODE UNIT · Python
_validation_error_handler
av1155/houndarr · src/houndarr/app.py:218
async def _validation_error_handler(
request: Request, exc: RequestValidationError
) -> HTMLResponse | JSONResponse:
"""Return a harmless HTML body (never JSON) for HTMX-initiated
validation errors.
Base.html opts 422 into the HTMX swap so server-emitted error
snippets actually render. FastAPI's default 422 body is JSON
(``{"detail": [...]}``), which would render as literal text
inside whatever slot the form targets. For HTMX requests we
ship an empty body with ``HX-Reswap: none`` so the swap is
suppressed (same visible behaviour as before the config flip)
and log the validation detail server-side for the operator.
Non-HTMX clients keep FastAPI's default JSON response so API
consumers and tests are unaffected.
"""
if is_hx_request(request):