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.
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
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 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>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/24814
Author: @JawafdehiBot
Created: 5/16/2026
Status: ❌ Closed
Base:
dev← Head:fix/chat-id-startswith-none-JAWA-1197📝 Commits (1)
6249485fix: 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 whenmetadata['chat_id']is None in the chat middleware.In
backend/open_webui/utils/middleware.py, replaced all unsafemetadata['chat_id'].startswith(...)calls withmetadata.get('chat_id', '').startswith(...)across:background_tasks_handler(2 call sites:local:andchannel:)non_streaming_chat_response_handler(4 call sites forchannel:)streaming_chat_response_handler(4 call sites forchannel:)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
metadata['chat_id'].startswith()calls againstNonevalues in chat response and background task handlers to prevent AttributeError crashes whenchat_idis None.Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.