[PR #23775] [CLOSED] fix: run outlet filters for API callers (streaming + non-streaming) #50414

Closed
opened 2026-04-30 03:07:27 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/23775
Author: @Classic298
Created: 4/16/2026
Status: Closed

Base: devHead: claude/fix-outlet-filter-handler-C46ht


📝 Commits (10+)

  • 7d894cd fix: run outlet filters for API callers without chat_id / message_id
  • 86bf3a6 refac: trim noisy comments in outlet_filter_handler
  • 7e11ba9 feat: fire outlet filters for API callers end-to-end (#23740, #23770)
  • 85e4223 fix: address automated review findings on outlet-for-API PR
  • df072d0 fix: address second review pass on outlet-for-API PR
  • 84d8cee fix: address third review pass on outlet-for-API PR
  • 63fd7bf fix: address fourth review pass on outlet-for-API PR
  • 68d86fa refac: trim comments
  • 346fa14 fix: address fifth review pass on outlet-for-API PR
  • 68da793 fix: address sixth review pass on outlet-for-API PR

📊 Changes

1 file changed (+362 additions, -89 deletions)

View changed files

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

📄 Description

Closes #23740, addresses #23770.

Upstream 70a6a24 made outlet_filter_handler work for temp chats (local: prefix) but left two gaps for API callers of /api/chat/completions:

  1. Streaming returns null when event_emitter reifies with a synthetic chat_id. streaming_chat_response_handler's main path (guarded by if event_emitter: at middleware.py:3376) has no explicit return in its inner response_handler — it returns None, leaving the API caller with an empty body. UI callers don't notice because they receive content via WebSocket events.
  2. Outlet filters never fire for API callers. Both the streaming fallback (else: at 4878) and the non-streaming handler gate outlet on event_emitter, so callers without a WebSocket session silently skip outlet entirely.

Contributor License Agreement

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 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/23775 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 4/16/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `claude/fix-outlet-filter-handler-C46ht` --- ### 📝 Commits (10+) - [`7d894cd`](https://github.com/open-webui/open-webui/commit/7d894cdea7a8f5a0fab276eca001fbd2988b6eeb) fix: run outlet filters for API callers without chat_id / message_id - [`86bf3a6`](https://github.com/open-webui/open-webui/commit/86bf3a655e7e94a277eb6f6705085171ac854464) refac: trim noisy comments in outlet_filter_handler - [`7e11ba9`](https://github.com/open-webui/open-webui/commit/7e11ba9a0884d33ecfbb2d17624c8d0944504031) feat: fire outlet filters for API callers end-to-end (#23740, #23770) - [`85e4223`](https://github.com/open-webui/open-webui/commit/85e422398c9f7bcdb20bfefaab77f8a147f22373) fix: address automated review findings on outlet-for-API PR - [`df072d0`](https://github.com/open-webui/open-webui/commit/df072d02d1d6df228215ce955ca42c76dba5a57b) fix: address second review pass on outlet-for-API PR - [`84d8cee`](https://github.com/open-webui/open-webui/commit/84d8cee6db2f82bb3bcc4e77536638184cecf110) fix: address third review pass on outlet-for-API PR - [`63fd7bf`](https://github.com/open-webui/open-webui/commit/63fd7bf633ad666630d61903f6c85ae4355b95c6) fix: address fourth review pass on outlet-for-API PR - [`68d86fa`](https://github.com/open-webui/open-webui/commit/68d86fae452fc1826cb6414f97ec1de957298c83) refac: trim comments - [`346fa14`](https://github.com/open-webui/open-webui/commit/346fa14796dc9f2b92c3813560d11b9d5eddf312) fix: address fifth review pass on outlet-for-API PR - [`68da793`](https://github.com/open-webui/open-webui/commit/68da793a87966a8cbfe84e724e173866ac49b020) fix: address sixth review pass on outlet-for-API PR ### 📊 Changes **1 file changed** (+362 additions, -89 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+362 -89) </details> ### 📄 Description Closes #23740, addresses #23770. Upstream `70a6a24` made `outlet_filter_handler` work for temp chats (`local:` prefix) but left two gaps for API callers of `/api/chat/completions`: 1. **Streaming returns null when event_emitter reifies with a synthetic chat_id.** `streaming_chat_response_handler`'s main path (guarded by `if event_emitter:` at `middleware.py:3376`) has no explicit return in its inner `response_handler` — it returns `None`, leaving the API caller with an empty body. UI callers don't notice because they receive content via WebSocket events. 2. **Outlet filters never fire for API callers.** Both the streaming fallback (`else:` at 4878) and the non-streaming handler gate outlet on `event_emitter`, so callers without a WebSocket session silently skip outlet entirely. ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [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. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <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-04-30 03:07:28 -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#50414