[PR #20242] [CLOSED] fix: prevent chat data corruption causing infinite loading spinner #41147

Closed
opened 2026-04-25 13:27:08 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/20242
Author: @Classic298
Created: 12/29/2025
Status: Closed

Base: devHead: fix-msg-structure


📝 Commits (1)

  • 4b356a3 fix: prevent chat data corruption causing infinite loading spinner

📊 Changes

5 files changed (+63 additions, -16 deletions)

View changed files

📝 backend/open_webui/main.py (+1 -0)
📝 backend/open_webui/models/chats.py (+22 -0)
📝 backend/open_webui/utils/middleware.py (+1 -0)
📝 src/lib/components/chat/Messages.svelte (+17 -4)
📝 src/lib/utils/index.ts (+22 -12)

📄 Description

Summary

This PR prevents chat data corruption that causes the "infinite loading spinner" bug where chats become permanently unloadable with no error messages.

Problem

Chats stored in the database can become corrupted when:

  1. Messages are saved without required fields (id, role, parentId, childrenIds)
  2. Error responses are stored as malformed objects without proper message structure
  3. Parent's childrenIds array is not updated when child messages are added

When the frontend tries to render corrupted chats, it enters an infinite loop or crashes silently.

Solution

Prevention (Backend)

  • Message upsert now ensures every message has id, parentId, and childrenIds fields before saving
  • When inserting a new message with a parentId, automatically adds the message ID to the parent's childrenIds
  • Error responses now include role field to prevent malformed messages

Defense (Frontend)

  • Message list functions now use a visited Set to detect circular references and prevent infinite loops
  • Added null/undefined guards to handle missing history data

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.

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/20242 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 12/29/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix-msg-structure` --- ### 📝 Commits (1) - [`4b356a3`](https://github.com/open-webui/open-webui/commit/4b356a37d2cb18b870a580619dc5b0d395d40cf2) fix: prevent chat data corruption causing infinite loading spinner ### 📊 Changes **5 files changed** (+63 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/main.py` (+1 -0) 📝 `backend/open_webui/models/chats.py` (+22 -0) 📝 `backend/open_webui/utils/middleware.py` (+1 -0) 📝 `src/lib/components/chat/Messages.svelte` (+17 -4) 📝 `src/lib/utils/index.ts` (+22 -12) </details> ### 📄 Description ## Summary This PR prevents chat data corruption that causes the "infinite loading spinner" bug where chats become permanently unloadable with no error messages. ## Problem Chats stored in the database can become corrupted when: 1. Messages are saved without required fields (id, role, parentId, childrenIds) 2. Error responses are stored as malformed objects without proper message structure 3. Parent's childrenIds array is not updated when child messages are added When the frontend tries to render corrupted chats, it enters an infinite loop or crashes silently. ## Solution ### Prevention (Backend) - Message upsert now ensures every message has id, parentId, and childrenIds fields before saving - When inserting a new message with a parentId, automatically adds the message ID to the parent's childrenIds - Error responses now include role field to prevent malformed messages ### Defense (Frontend) - Message list functions now use a visited Set to detect circular references and prevent infinite loops - Added null/undefined guards to handle missing history data ### Contributor License Agreement 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-25 13:27:08 -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#41147