Bug: ImproperlyConfiguredException — status code 204 does not support a response body
Describe the bug
apiup crashes at startup when the spec contains a 204 response (e.g. DELETE routes).
Error
litestar.exceptions.http_exceptions.ImproperlyConfiguredException:
A status code 204, 304 or in the range below 200 does not support a response body.
Root cause
All handlers returned a Response with a body. Litestar strictly enforces that 204 and 304 responses have no body.
Fix
In _make_handler(), detect no-body status codes and return None instead:
_NO_BODY_CODES = frozenset({204, 304})
if status_code in _NO_BODY_CODES:
async def _handler() -> None:
return None
Labels
bug
Bug:
ImproperlyConfiguredException— status code 204 does not support a response bodyDescribe the bug
apiupcrashes at startup when the spec contains a204response (e.g. DELETE routes).Error
Root cause
All handlers returned a
Responsewith a body. Litestar strictly enforces that204and304responses have no body.Fix
In
_make_handler(), detect no-body status codes and returnNoneinstead:Labels
bug