[PR #17516] [CLOSED] fix: handle None usage data in chat response processing #24453

Closed
opened 2026-04-20 05:24:41 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/17516
Author: @NibbinNone
Created: 9/17/2025
Status: Closed

Base: devHead: dev


📝 Commits (1)

  • 663410c fix: handle None usage data in chat response processing

📊 Changes

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

View changed files

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

📄 Description

Update usage data handling to use 'or {}' instead of default parameter to properly handle None values from API responses.

some api server return data like

data: {"id": "chatcmpl-5jR1Fhd9KUk4P6N3zWo2y4coMscGu", "object": "chat.completion.chunk", "created": 1758113545, "model": "claude-neptune-v3", "choices": [{"index": 0, "delta": {"role": "assistant", "content": "3会更精确。"}, "logprobs": null, "finish_reason": null}], "usage": null, "system_fingerprint": "fp_d576307f90"}

The code usage = data.get("usage", {}) gets None, which causes the open-webui to not display the message correctly.

Screenshot_20250917_211643_ B@95c440d


🔄 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/17516 **Author:** [@NibbinNone](https://github.com/NibbinNone) **Created:** 9/17/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `dev` --- ### 📝 Commits (1) - [`663410c`](https://github.com/open-webui/open-webui/commit/663410c8b0a6be1f7371c755e4728c064041bc00) fix: handle None usage data in chat response processing ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+1 -1) </details> ### 📄 Description Update usage data handling to use 'or {}' instead of default parameter to properly handle None values from API responses. some api server return data like ``` data: {"id": "chatcmpl-5jR1Fhd9KUk4P6N3zWo2y4coMscGu", "object": "chat.completion.chunk", "created": 1758113545, "model": "claude-neptune-v3", "choices": [{"index": 0, "delta": {"role": "assistant", "content": "3会更精确。"}, "logprobs": null, "finish_reason": null}], "usage": null, "system_fingerprint": "fp_d576307f90"} ``` The code `usage = data.get("usage", {})` gets None, which causes the open-webui to not display the message correctly. ![Screenshot_20250917_211643_ B@95c440d](https://github.com/user-attachments/assets/0e79a94b-5975-4375-931d-600e75f2a34e) --- <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-20 05:24: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#24453