Files
open-webui/backend/open_webui
PVBLIC Foundation 1cbfa1be06 fix: handle chat_id=None in event emitter and Drive client
Two runtime regressions surfaced from server-to-server callers (tools,
automations, llm_council) hitting /api/chat/completions without a
chat_id, plus one missed await on the async OAuthSessions API.

1) socket/main.py get_event_emitter
   - request_info.get('chat_id', '').startswith(...) returned None when
     chat_id was explicitly None (dict.get default only applies when the
     key is missing entirely), causing 'NoneType' object has no attribute
     'startswith' and a 400 on every tool-driven completion request.
   - Use `(chat_id or '')` for both startswith calls.

2) utils/middleware.py background_tasks_handler
   - Same pattern: tightened the chat_id presence check from
     `'chat_id' in metadata` (False-positive on None values) to
     `metadata.get('chat_id')`. Also defensively switched two existing
     `metadata.get('chat_id', '').startswith(...)` checks to use the
     `or ''` pattern.

3) utils/google_drive_client.py create_drive_client_for_user
   - OAuthSessions.get_session_by_provider_and_user_id is now async
     (v0.9.5); the missing await produced
     "'coroutine' object has no attribute 'id'" when accessing
     .id on the returned coroutine and prevented all Drive sync runs.

Made-with: Cursor
2026-05-11 14:20:18 -07:00
..