[PR #24814] [CLOSED] fix: guard chat_id NoneType in startswith calls #115175

Closed
opened 2026-05-18 16:07:41 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/24814
Author: @JawafdehiBot
Created: 5/16/2026
Status: Closed

Base: devHead: fix/chat-id-startswith-none-JAWA-1197


📝 Commits (1)

  • 6249485 fix: guard chat_id NoneType in startswith calls

📊 Changes

1 file changed (+10 additions, -10 deletions)

View changed files

📝 backend/open_webui/utils/middleware.py (+10 -10)

📄 Description

Description

Prevent 'NoneType' object has no attribute 'startswith' crashes when metadata['chat_id'] is None in the chat middleware.

In backend/open_webui/utils/middleware.py, replaced all unsafe metadata['chat_id'].startswith(...) calls with metadata.get('chat_id', '').startswith(...) across:

  • background_tasks_handler (2 call sites: local: and channel:)
  • non_streaming_chat_response_handler (4 call sites for channel:)
  • streaming_chat_response_handler (4 call sites for channel:)

Linked Issue

No upstream issue linked — this is a defensive fix discovered during production deployment of Open WebUI. See /JAWA/issues/JAWA-1197 for internal tracking.

Paperclip-Run-Id: 631d3477-e895-44ae-8d4e-623796b39a20

Changelog Entry

Fixed

  • Guard metadata['chat_id'].startswith() calls against None values in chat response and background task handlers to prevent AttributeError crashes when chat_id is None.

Contributor License Agreement


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/24814 **Author:** [@JawafdehiBot](https://github.com/JawafdehiBot) **Created:** 5/16/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/chat-id-startswith-none-JAWA-1197` --- ### 📝 Commits (1) - [`6249485`](https://github.com/open-webui/open-webui/commit/62494853f6c19b57eb548d0b14741efea375e4cf) fix: guard chat_id NoneType in startswith calls ### 📊 Changes **1 file changed** (+10 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+10 -10) </details> ### 📄 Description ## Description Prevent `'NoneType' object has no attribute 'startswith'` crashes when `metadata['chat_id']` is None in the chat middleware. In `backend/open_webui/utils/middleware.py`, replaced all unsafe `metadata['chat_id'].startswith(...)` calls with `metadata.get('chat_id', '').startswith(...)` across: - `background_tasks_handler` (2 call sites: `local:` and `channel:`) - `non_streaming_chat_response_handler` (4 call sites for `channel:`) - `streaming_chat_response_handler` (4 call sites for `channel:`) ## Linked Issue No upstream issue linked — this is a defensive fix discovered during production deployment of Open WebUI. See [/JAWA/issues/JAWA-1197](/JAWA/issues/JAWA-1197) for internal tracking. Paperclip-Run-Id: 631d3477-e895-44ae-8d4e-623796b39a20 ## Changelog Entry ### Fixed - Guard `metadata['chat_id'].startswith()` calls against `None` values in chat response and background task handlers to prevent AttributeError crashes when `chat_id` is None. --- ### Contributor License Agreement - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-18 16:07:41 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#115175