From 06f8ee0e423c46e98f4a9beb9b07a3bcfd0bc031 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Mon, 11 May 2026 00:32:56 +0200 Subject: [PATCH] fix: handle None chat_id in get_event_emitter channel-mode check Direct API callers to /api/chat/completions pass no chat_id, so metadata['chat_id'] ends up None. dict.get('chat_id', '') returns None (not '') when the key is present-with-None, so the channels-streaming branch added in v0.9.5 (0037baeb2) crashed with 'NoneType' object has no attribute 'startswith', surfacing as HTTP 400 to the caller. Fixes #24553. --- backend/open_webui/socket/main.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/socket/main.py b/backend/open_webui/socket/main.py index d59ff53277..10959b30f4 100644 --- a/backend/open_webui/socket/main.py +++ b/backend/open_webui/socket/main.py @@ -898,8 +898,9 @@ async def _make_channel_emitter(request_info): async def get_event_emitter(request_info, update_db=True): - # Channel mode: route pipeline output to channel message updates - if request_info.get('chat_id', '').startswith('channel:'): + # Channel mode: route pipeline output to channel message updates. + # `or ''` (not the .get default) because chat_id may be present as None. + if (request_info.get('chat_id') or '').startswith('channel:'): return await _make_channel_emitter(request_info) async def __event_emitter__(event_data):