From 7ab0478f315aba09467822d608ff8d9e7b5f39be Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Fri, 3 Apr 2026 17:17:28 +0200 Subject: [PATCH] fix: wrap non-JSON SSE error responses in JSON so middleware handles them --- backend/open_webui/routers/openai.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/routers/openai.py b/backend/open_webui/routers/openai.py index ce290d09b2..0c0228cb52 100644 --- a/backend/open_webui/routers/openai.py +++ b/backend/open_webui/routers/openai.py @@ -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(