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.
This commit is contained in:
Classic298 2026-05-11 00:32:56 +02:00
parent 18ff358c15
commit 06f8ee0e42

View file

@ -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):