fix(backend): delete_attachment 204 response must not declare a body

Litestar validates that handlers with 204 status codes cannot return
a response body. The delete_attachment handler was declared as
-> Response and returned Response(content=None, status_code=204),
which caused ImproperlyConfiguredException at startup and crashed
all workers. Change return type to None and move status_code to the
@delete decorator.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
gongzhiyong
2026-04-08 18:39:16 +08:00
co-authored by Claude Opus 4.6
parent 5fddf4ff2b
commit 1ff0b9d4ff
+2 -4
View File
@@ -181,8 +181,8 @@ async def download_attachment(attachment_id: str) -> Response:
)
@delete("/api/attachments/{attachment_id:str}")
async def delete_attachment(attachment_id: str) -> Response:
@delete("/api/attachments/{attachment_id:str}", status_code=204)
async def delete_attachment(attachment_id: str) -> None:
"""DELETE /api/attachments/:id -- Delete attachment (blob + DB record)."""
async with async_session_factory() as session:
attachment = await session.get(Attachment, attachment_id)
@@ -211,5 +211,3 @@ async def delete_attachment(attachment_id: str) -> Response:
# Delete from database
await session.delete(attachment)
await session.commit()
return Response(content=None, status_code=204)