fix: wrap non-JSON SSE error responses in JSON so middleware handles them

This commit is contained in:
Classic298 2026-04-03 17:17:28 +02:00 • committed by DrMelone
parent 7c527837f0
commit 7ab0478f31

View file

@ -1206,7 +1206,10 @@ async def generate_chat_completion(
error_json = json.loads(error_body)
return JSONResponse(status_code=r.status, content=error_json)
except json.JSONDecodeError:
return PlainTextResponse(status_code=r.status, content=error_body)
return JSONResponse(
status_code=r.status,
content={"error": {"message": error_body, "code": r.status}},
)
streaming = True
return StreamingResponse(