From dd514ee20bf2d6c2d732b431cf27c75d9cc58d33 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Fri, 24 Jul 2026 00:49:18 +0200 Subject: [PATCH] fix: persist upstream streaming error lines by awaiting the message upsert (#27365) The branch that normalizes plain JSON error lines from streaming upstreams (lines without the SSE data: prefix) called Chats.upsert_message_to_chat_by_id_and_message_id without await. The coroutine was never executed, so the error was never written to the chat and Python emitted a "coroutine was never awaited" RuntimeWarning instead. The frontend still received the error event, but after a reload the message showed no trace of the failure. The parallel error-persist branch further down the same handler already awaits the call; this aligns the two. --- backend/open_webui/utils/middleware.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index c4a042d9e1..7c51537623 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -4116,7 +4116,7 @@ async def streaming_chat_response_handler(response, ctx): raw_error = raw_obj.get('error') if isinstance(raw_obj, dict) else None if raw_error: try: - Chats.upsert_message_to_chat_by_id_and_message_id( + await Chats.upsert_message_to_chat_by_id_and_message_id( metadata['chat_id'], metadata['message_id'], {