[PR #24899] [CLOSED] [JAWA-1480] Fix NoneType startswith crash in get_event_emitter when chat_id is None #131582

Closed
opened 2026-05-21 17:15:57 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

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

Base: mainHead: JAWA-1480-fix-chat-none-startswith


📝 Commits (10+)

  • febbaf7 fix: interpolate template vars in MCP connection headers
  • e6ceefd add deployment config for chat.jawafdehi.org
  • 5863705 add persistent chat_logs volume to jawafdehi-mcp service
  • b0ff02f ci: add jawafdehi-custom branch to docker-build workflow triggers
  • bd7c7f7 Merge pull request #2 from Jawafdehi/jawafdehi-custom-ci-ghcr
  • e4f89de Simplify docker-build workflow to amd64-only builds
  • 1f05aae Add step to make GHCR package public for host pulls
  • 6e8a006 Fix package visibility API endpoint to org-scoped
  • eb0652c Export image as tar.gz artifact for offline deploy
  • c330e5a Switch from GHCR to Docker Hub (public images, no auth needed for pull)

📊 Changes

34 files changed (+8016 additions, -903 deletions)

View changed files

.github/workflows/deploy-chat.yml (+63 -0)
📝 .github/workflows/docker-build.yaml (+16 -881)
📝 backend/open_webui/config.py (+12 -15)
📝 backend/open_webui/env.py (+0 -2)
📝 backend/open_webui/socket/main.py (+2 -2)
📝 backend/open_webui/utils/middleware.py (+3 -3)
deploy/chat/.env.example (+12 -0)
deploy/chat/README.md (+124 -0)
deploy/chat/bin/bootstrap-config.sh (+237 -0)
deploy/chat/bin/deploy.sh (+88 -0)
deploy/chat/code/middleware.py (+5249 -0)
deploy/chat/code/tools_models.py (+303 -0)
deploy/chat/code/tools_utils.py (+1501 -0)
deploy/chat/configs/README.md (+41 -0)
deploy/chat/configs/knowledge/collections.json (+14 -0)
deploy/chat/configs/models/jawafdehi-caseworker.json (+29 -0)
deploy/chat/docker-compose.prod.yml (+86 -0)
deploy/chat/docker-compose.yml (+83 -0)
deploy/chat/mcp.env.example (+29 -0)
deploy/chat/nginx/chat.jawafdehi.org.conf (+36 -0)

...and 14 more files

📄 Description

Root Cause

When chat.jawafdehi.org is called via API key (non-WebSocket session), chat_id in metadata is None. In get_event_emitter(), the expression request_info.get('chat_id', '') returns None (not the default empty string) because the key exists in the dict with value None. Calling .startswith() on None crashes with:

'NoneType' object has no attribute 'startswith'

This breaks ALL /api/chat/completions requests via API key auth.

Fix

Two lines in backend/open_webui/socket/main.py:

  • Line 902: if (request_info.get('chat_id') or '').startswith('channel:')
  • Line 920: if update_db and message_id and not (request_info.get('chat_id') or '').startswith('local:')

The or '' pattern safely coalesces None to empty string.

Verification

  • Live-patched running container on monal-instance1, restarted, confirmed /api/chat/completions returns 200 with valid responses for all models (deepseek-v4-pro, kimi-k2.6)
  • Backend OpenCode provider (opencode.ai/zen/go/v1) confirmed working independently

🔄 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/24899 **Author:** [@JawafdehiBot](https://github.com/JawafdehiBot) **Created:** 5/19/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `JAWA-1480-fix-chat-none-startswith` --- ### 📝 Commits (10+) - [`febbaf7`](https://github.com/open-webui/open-webui/commit/febbaf7a62fa927f9593d9698c944f8c7cab29cf) fix: interpolate template vars in MCP connection headers - [`e6ceefd`](https://github.com/open-webui/open-webui/commit/e6ceefd1f633741a8276b650955a759eb6bf7526) add deployment config for chat.jawafdehi.org - [`5863705`](https://github.com/open-webui/open-webui/commit/5863705127b39a6ccb26e6028651edddc3013874) add persistent chat_logs volume to jawafdehi-mcp service - [`b0ff02f`](https://github.com/open-webui/open-webui/commit/b0ff02f14aa9b47f666f815a97ef155aad368324) ci: add jawafdehi-custom branch to docker-build workflow triggers - [`bd7c7f7`](https://github.com/open-webui/open-webui/commit/bd7c7f702f82271ba94eda31200fa413acde18db) Merge pull request #2 from Jawafdehi/jawafdehi-custom-ci-ghcr - [`e4f89de`](https://github.com/open-webui/open-webui/commit/e4f89de595b9a96237c00a9e1d600de2ddde2a94) Simplify docker-build workflow to amd64-only builds - [`1f05aae`](https://github.com/open-webui/open-webui/commit/1f05aaeae82138ed77154e7080ffc2bc5ba7d1d7) Add step to make GHCR package public for host pulls - [`6e8a006`](https://github.com/open-webui/open-webui/commit/6e8a006ada570cbd0436bf2d227eb81effa719fc) Fix package visibility API endpoint to org-scoped - [`eb0652c`](https://github.com/open-webui/open-webui/commit/eb0652c899afdabe16c3b0baba8d9a949258d409) Export image as tar.gz artifact for offline deploy - [`c330e5a`](https://github.com/open-webui/open-webui/commit/c330e5a7ad388f238c608f13f2f3c0bc2aa5b117) Switch from GHCR to Docker Hub (public images, no auth needed for pull) ### 📊 Changes **34 files changed** (+8016 additions, -903 deletions) <details> <summary>View changed files</summary> ➕ `.github/workflows/deploy-chat.yml` (+63 -0) 📝 `.github/workflows/docker-build.yaml` (+16 -881) 📝 `backend/open_webui/config.py` (+12 -15) 📝 `backend/open_webui/env.py` (+0 -2) 📝 `backend/open_webui/socket/main.py` (+2 -2) 📝 `backend/open_webui/utils/middleware.py` (+3 -3) ➕ `deploy/chat/.env.example` (+12 -0) ➕ `deploy/chat/README.md` (+124 -0) ➕ `deploy/chat/bin/bootstrap-config.sh` (+237 -0) ➕ `deploy/chat/bin/deploy.sh` (+88 -0) ➕ `deploy/chat/code/middleware.py` (+5249 -0) ➕ `deploy/chat/code/tools_models.py` (+303 -0) ➕ `deploy/chat/code/tools_utils.py` (+1501 -0) ➕ `deploy/chat/configs/README.md` (+41 -0) ➕ `deploy/chat/configs/knowledge/collections.json` (+14 -0) ➕ `deploy/chat/configs/models/jawafdehi-caseworker.json` (+29 -0) ➕ `deploy/chat/docker-compose.prod.yml` (+86 -0) ➕ `deploy/chat/docker-compose.yml` (+83 -0) ➕ `deploy/chat/mcp.env.example` (+29 -0) ➕ `deploy/chat/nginx/chat.jawafdehi.org.conf` (+36 -0) _...and 14 more files_ </details> ### 📄 Description ## Root Cause When chat.jawafdehi.org is called via API key (non-WebSocket session), `chat_id` in metadata is `None`. In `get_event_emitter()`, the expression `request_info.get('chat_id', '')` returns `None` (not the default empty string) because the key *exists* in the dict with value `None`. Calling `.startswith()` on `None` crashes with: ``` 'NoneType' object has no attribute 'startswith' ``` This breaks ALL `/api/chat/completions` requests via API key auth. ## Fix Two lines in `backend/open_webui/socket/main.py`: - Line 902: `if (request_info.get('chat_id') or '').startswith('channel:')` - Line 920: `if update_db and message_id and not (request_info.get('chat_id') or '').startswith('local:')` The `or ''` pattern safely coalesces `None` to empty string. ## Verification - Live-patched running container on monal-instance1, restarted, confirmed `/api/chat/completions` returns 200 with valid responses for all models (deepseek-v4-pro, kimi-k2.6) - Backend OpenCode provider (opencode.ai/zen/go/v1) confirmed working independently ## Links - Paperclip issue: [/JAWA/issues/JAWA-1480](/JAWA/issues/JAWA-1480) - Paperclip-Run-Id: 476582f3-91bf-4491-8f4d-e8202fa27681 --- <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-21 17:15:57 -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#131582