From 9d6b17ffbc9f533a9708e3e660bc2dccada957a2 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Sat, 26 Sep 2026 05:18:23 +0200 Subject: [PATCH] fix: errors on Responses API connections are not shown or not kept after a reload (#31439) With a connection set to the Responses API, when the provider reported a reply as failed, the error showed while streaming but was gone after a reload, leaving an empty reply. Some other provider errors never showed up at all, not even while streaming. Both kinds of error now show up and are still there after a reload, the same as on Chat Completions connections. Fixes #31433 --- backend/open_webui/utils/middleware.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 754b90c0c0..5407085707 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -933,6 +933,9 @@ def handle_responses_streaming_event( error = data.get('response', {}).get('error', {}) return current_output, {'error': error} + elif event_type == 'error': + return current_output, {'error': data} + else: return current_output, None @@ -5113,8 +5116,8 @@ async def streaming_chat_response_handler(response, ctx): 'data': data, } ) - # Check for Responses API events (type field starts with "response.") - elif data.get('type', '').startswith('response.'): + # Check for Responses API events + elif data.get('type', '').startswith('response.') or data.get('type', '') == 'error': response_data_type = data.get('type', '') response_data_is_delta = response_data_type.endswith('.delta') output, response_metadata = handle_responses_streaming_event(data, output) @@ -5173,6 +5176,20 @@ async def streaming_chat_response_handler(response, ctx): response_metadata['usage'] = usage if response_metadata.get('error'): + log.error( + 'Provider returned error (streaming): %s', response_metadata['error'] + ) + if save_to_chat: + try: + await Chats.upsert_message_to_chat_by_id_and_message_id( + metadata['chat_id'], + metadata['message_id'], + { + 'error': {'content': response_metadata['error']}, + }, + ) + except Exception: + pass await event_emitter( { 'type': 'chat:completion',