Skip to content

Bug: ImproperlyConfiguredException — status code 204 does not support a response body #10

@roebi

Description

@roebi

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingtriage

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions