issue: Bug: Lack of Data Integrity Validation on Chat Model Causes Silent Failure and Frontend Deadlock #5606

Open
opened 2025-11-11 16:26:07 -06:00 by GiteaMirror · 5 comments
Owner

Originally created by @robotmikhro on GitHub (Jun 21, 2025).

Check Existing Issues

  • I have searched the existing issues and discussions.
  • I am using the latest version of Open WebUI.

Installation Method

Git Clone

Open WebUI Version

0.6.15

Ollama Version (if applicable)

No response

Operating System

Ubuntu 22.04.5 LTS(Jammy Jellyfish)

Browser (if applicable)

Firefox 139.0.4 (64-bit)

Confirmation

  • I have read and followed all instructions in README.md.
  • I am using the latest version of both Open WebUI and Ollama.
  • I have included the browser console logs.
  • I have included the Docker container logs.
  • I have provided every relevant configuration, setting, and environment variable used in my setup.
  • I have clearly listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc).
  • I have documented step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation. My steps:
  • Start with the initial platform/version/OS and dependencies used,
  • Specify exact install/launch/configure commands,
  • List URLs visited, user input (incl. example values/emails/passwords if needed),
  • Describe all options and toggles enabled or changed,
  • Include any files or environmental changes,
  • Identify the expected and actual result at each stage,
  • Ensure any reasonably skilled user can follow and hit the same issue.

Expected Behavior

Area: Backend, Frontend, Data Integrity

Description

The application's backend does not perform sufficient data integrity checks on the chat object model before persisting it to the database. This allows structurally inconsistent or corrupted chat data (e.g., messages with missing parentId links) to be saved without any errors or warnings being logged.

When the frontend subsequently attempts to render this structurally flawed data, its rendering logic enters an unrecoverable state, such as an infinite loop or a state management deadlock. This results in the UI hanging indefinitely on a loading spinner, preventing the user from ever viewing the chat.

This is a fundamental data handling issue, not just an import/export problem. The import feature is simply the most direct way to introduce this kind of corrupted data and reproduce the bug.

Expected Behavior

The application should be resilient to data inconsistencies:

  • Backend: Before saving a chat object, the backend must validate its structural integrity. It should repair common issues (like broken parent-child links) or reject the data with a clear error log if it's irrecoverably malformed.
  • Frontend: The UI components should be robust enough to handle minor data imperfections without entering a deadlock, ensuring the application remains responsive.

Reasoning: Root Cause Analysis

The core issue is a lack of data validation and sanitization in the backend logic that handles the Chat model, "MAYBE" within backend/open_webui/models/chats.py.

  1. The Vulnerability: The backend implicitly trusts the structural integrity of the chat JSON object it receives. It does not validate the parent-child relationships within the message tree. In the provided example, the message 23067407-327f-4167-bac6-5804080aed15 is an "orphan" message—it has no parentId key, and no other message lists it as a child. This process completes without any exceptions or warnings, as the backend logic does not currently validate the internal consistency of the chat tree.

  2. The Consequence: When the frontend fetches this chat, its rendering logic receives an inconsistent state. It may, for example, iterate over one list of messages while trying to look up relationships in a different, out-of-sync map. When it encounters an inconsistency like the orphan message, the logic to determine the next message to render or to build the conversational tree can enter an unrecoverable state. This results in a logical deadlock or an infinite loop, which prevents the rendering process from ever completing, causing the persistent loading indicator.

Actual Behavior

The application hangs indefinitely on a loading spinner.

A critical diagnostic detail is that this failure is silent. No errors are generated in the browser's developer console, and no relevant warnings or errors appear in the Open-WebUI backend logs during the import or subsequent access of the chat. This points to a logical deadlock in the frontend rendering process, triggered by data that was silently accepted as "valid" by the backend.

Steps to Reproduce

  1. Introduce a structurally inconsistent chat object into the database, for example, by using the "Import Chat" feature with the malformed JSON provided below.
  2. The import process will appear to succeed, as no validation is performed on the chat's internal structure.
  3. Attempt to open and view the newly imported chat from the chat list.

Example of Malformed Data to Reproduce the Bug

The following JSON data, with its full content, reliably triggers the bug. The key structural flaws are:

  1. The message 23067407-327f-4167-bac6-5804080aed15 is an "orphan" message, as it is missing the parentId key.
  2. The top-level messages array is out of sync with the history.messages map (it is missing the orphan message).
[
  {
    "id": "8a3351f4-79c1-4731-8826-d5783944b0c2",
    "user_id": "fe7bbdce-2468-4ce4-aa02-00edd8c48e76",
    "title": "Fitur Applicant",
    "chat": {
      "id": "",
      "title": "Fitur Applicant",
      "models": ["claude-4-sonnet-latest"],
      "params": {},
      "history": {
        "messages": {
          "2d16b51a-2ae5-433f-a8c9-dea4999a41e2": {
            "id": "2d16b51a-2ae5-433f-a8c9-dea4999a41e2",
            "parentId": null,
            "childrenIds": ["c3cd2a61-23cb-40d4-8898-8c6b72b2c155"],
            "role": "user",
            "content": "Anda adalah programmer/software engineer laravel 11 ahli, bertindaklah sebagaimana praktisi ahli bertindak. Anda juga harus teliti dan sangat berhati-hati. Selalu generate code terbaik yang clean dan readable menurut best practice. Anda juga harus berpikir straight to the poin dan tidak berhalusinasi. Dalam analisa kode, anda harus teliti dan pastikan tidak ada bagian yang luput dari inspeksi anda. Berikan penjelasan yang clear,detail,transparant.",
            "timestamp": 1750304687,
            "models": ["claude-4-sonnet-latest"]
          },
          "c3cd2a61-23cb-40d4-8898-8c6b72b2c155": {
            "parentId": "2d16b51a-2ae5-433f-a8c9-dea4999a41e2",
            "id": "c3cd2a61-23cb-40d4-8898-8c6b72b2c155",
            "childrenIds": [],
            "role": "assistant",
            "content": "I understand you're looking for Laravel 11 expertise. I'm ready to help you with Laravel development questions, code reviews, best practices, and any technical challenges you're facing.\n\nAs a Laravel specialist, I can assist with:\n- Clean, readable code following Laravel conventions\n- Performance optimization\n- Security best practices\n- Database design and Eloquent relationships\n- API development\n- Testing strategies\n- Architecture decisions\n\nWhat specific Laravel 11 task or problem would you like help with today? Please share your code, requirements, or questions and I'll provide detailed, practical solutions.",
            "model": "claude-4-sonnet-latest",
            "modelName": "Claude 4 Sonnet Exp",
            "modelIdx": 0,
            "timestamp": 1750304687,
            "lastSentence": "As a Laravel specialist, I can assist with:\nClean, readable code following Laravel conventions\nPerformance optimization\nSecurity best practices\nDatabase design and Eloquent relationships\nAPI development\nTesting strategies\nArchitecture decisions\nWhat specific Laravel 11 task or problem would you like help with today?",
            "usage": {
              "prompt_tokens": 508,
              "completion_tokens": 125,
              "total_tokens": 633,
              "prompt_tokens_details": {
                "cached_tokens": 0,
                "cache_creation_input_tokens": 0
              }
            },
            "done": true,
            "followUps": [
              "How can I optimize Eloquent query performance in Laravel 11 for large datasets?",
              "What's the best approach to implement multi-tenancy in a Laravel 11 application?",
              "Can you guide me on using Laravel 11's new Blade features effectively?",
              "How should I structure API resources for a RESTful Laravel 11 backend?",
              "What are the latest security practices for Laravel 11 authentication systems?"
            ]
          },
          "23067407-327f-4167-bac6-5804080aed15": {
            "model": "claude-4-sonnet-latest",
            "content": "I'm ready to review your form.blade.php code. However, I don't see the actual code content in your message. Could you please share the code from your form.blade.php file so I can analyze it and provide detailed feedback?\n\nOnce you share the code, I'll examine it for:\n- Laravel best practices compliance\n- Security considerations (CSRF protection, validation, etc.)\n- Code structure and readability\n- Potential improvements\n- Any issues that need attention\n\nPlease paste your form.blade.php code and I'll give you a thorough analysis.",
            "followUps": [
              "Could you check if my CSRF protection is implemented correctly in the form?",
              "How can I validate the form inputs in the controller using Laravel best practices?",
              "What are some tips to improve the readability and structure of my Blade form code?",
              "Are there any security vulnerabilities I should be aware of when handling form submissions in Laravel?",
              "Should I be using FormRequest classes for validation, and how do I set them up?"
            ]
          }
        },
        "currentId": "23067407-327f-4167-bac6-5804080aed15"
      },
      "messages": [
        {
          "id": "2d16b51a-2ae5-433f-a8c9-dea4999a41e2",
          "parentId": null,
          "childrenIds": ["c3cd2a61-23cb-40d4-8898-8c6b72b2c155"],
          "role": "user",
          "content": "Anda adalah programmer/software engineer laravel 11 ahli, bertindaklah sebagaimana praktisi ahli bertindak. Anda juga harus teliti dan sangat berhati-hati. Selalu generate code terbaik yang clean dan readable menurut best practice. Anda juga harus berpikir straight to the poin dan tidak berhalusinasi. Dalam analisa kode, anda harus teliti dan pastikan tidak ada bagian yang luput dari inspeksi anda. Berikan penjelasan yang clear,detail,transparant.",
          "timestamp": 1750304687,
          "models": ["claude-4-sonnet-latest"]
        },
        {
          "parentId": "2d16b51a-2ae5-433f-a8c9-dea4999a41e2",
          "id": "c3cd2a61-23cb-40d4-8898-8c6b72b2c155",
          "childrenIds": [],
          "role": "assistant",
          "content": "I understand you're looking for Laravel 11 expertise. I'm ready to help you with Laravel development questions, code reviews, best practices, and any technical challenges you're facing.\n\nAs a Laravel specialist, I can assist with:\n- Clean, readable code following Laravel conventions\n- Performance optimization\n- Security best practices\n- Database design and Eloquent relationships\n- API development\n- Testing strategies\n- Architecture decisions\n\nWhat specific Laravel 11 task or problem would you like help with today? Please share your code, requirements, or questions and I'll provide detailed, practical solutions.",
          "model": "claude-4-sonnet-latest",
          "modelName": "Claude 4 Sonnet Exp",
          "modelIdx": 0,
          "timestamp": 1750304687,
          "lastSentence": "As a Laravel specialist, I can assist with:\nClean, readable code following Laravel conventions\nPerformance optimization\nSecurity best practices\nDatabase design and Eloquent relationships\nAPI development\nTesting strategies\nArchitecture decisions\nWhat specific Laravel 11 task or problem would you like help with today?",
          "usage": {
            "prompt_tokens": 508,
            "completion_tokens": 125,
            "total_tokens": 633,
            "prompt_tokens_details": {
              "cached_tokens": 0,
              "cache_creation_input_tokens": 0
            }
          },
          "done": true,
          "followUps": [
            "How can I optimize Eloquent query performance in Laravel 11 for large datasets?",
            "What's the best approach to implement multi-tenancy in a Laravel 11 application?",
            "Can you guide me on using Laravel 11's new Blade features effectively?",
            "How should I structure API resources for a RESTful Laravel 11 backend?",
            "What are the latest security practices for Laravel 11 authentication systems?"
          ]
        }
      ],
      "tags": [],
      "timestamp": 1750304687862,
      "files": []
    },
    "updated_at": 1750307488,
    "created_at": 1750304687,
    "share_id": null,
    "archived": false,
    "pinned": false,
    "meta": {},
    "folder_id": null
  }
]

Screenshots

Image

Additional Information

This bug was identified through a detailed debugging process that revealed several key insights which may be helpful for the development team:

  1. Specific Nature of Data Corruption: The issue was traced back to a specific type of structural inconsistency in the chat's JSON data. The primary flaw was an "orphan" message object that completely lacked a parentId key, effectively detaching it from the conversational tree. This was compounded by the top-level messages array being out of sync with the history.messages map, as it did not contain the orphan message.

  2. Frontend Failure Mode is a Logical Deadlock, Not a Crash: A crucial observation is that this issue does not produce any errors in the browser's developer console. This indicates the problem is not a simple runtime TypeError from accessing an undefined property. Instead, it suggests the frontend's rendering logic enters an unrecoverable state—likely an infinite loop or a state management deadlock—when it tries to process the inconsistent message tree. It cannot determine the correct sequence of messages to render, and thus hangs.

Originally created by @robotmikhro on GitHub (Jun 21, 2025). ### Check Existing Issues - [x] I have searched the existing issues and discussions. - [x] I am using the latest version of Open WebUI. ### Installation Method Git Clone ### Open WebUI Version 0.6.15 ### Ollama Version (if applicable) _No response_ ### Operating System Ubuntu 22.04.5 LTS(Jammy Jellyfish) ### Browser (if applicable) Firefox 139.0.4 (64-bit) ### Confirmation - [x] I have read and followed all instructions in `README.md`. - [x] I am using the latest version of **both** Open WebUI and Ollama. - [x] I have included the browser console logs. - [x] I have included the Docker container logs. - [x] I have **provided every relevant configuration, setting, and environment variable used in my setup.** - [x] I have clearly **listed every relevant configuration, custom setting, environment variable, and command-line option that influences my setup** (such as Docker Compose overrides, .env values, browser settings, authentication configurations, etc). - [x] I have documented **step-by-step reproduction instructions that are precise, sequential, and leave nothing to interpretation**. My steps: - Start with the initial platform/version/OS and dependencies used, - Specify exact install/launch/configure commands, - List URLs visited, user input (incl. example values/emails/passwords if needed), - Describe all options and toggles enabled or changed, - Include any files or environmental changes, - Identify the expected and actual result at each stage, - Ensure any reasonably skilled user can follow and hit the same issue. ### Expected Behavior **Area:** Backend, Frontend, Data Integrity ### Description The application's backend does not perform sufficient data integrity checks on the chat object model before persisting it to the database. This allows structurally inconsistent or corrupted chat data (e.g., messages with missing `parentId` links) to be saved **without any errors or warnings being logged**. When the frontend subsequently attempts to render this structurally flawed data, its rendering logic enters an unrecoverable state, such as an infinite loop or a state management deadlock. This results in the UI hanging indefinitely on a loading spinner, preventing the user from ever viewing the chat. This is a fundamental data handling issue, not just an import/export problem. The import feature is simply the most direct way to introduce this kind of corrupted data and reproduce the bug. ### Expected Behavior The application should be resilient to data inconsistencies: - **Backend:** Before saving a chat object, the backend must validate its structural integrity. It should repair common issues (like broken parent-child links) or reject the data with a clear error log if it's irrecoverably malformed. - **Frontend:** The UI components should be robust enough to handle minor data imperfections without entering a deadlock, ensuring the application remains responsive. ### Reasoning: Root Cause Analysis The core issue is a **lack of data validation and sanitization in the backend logic** that handles the `Chat` model, "MAYBE" within `backend/open_webui/models/chats.py`. 1. **The Vulnerability:** The backend implicitly trusts the structural integrity of the `chat` JSON object it receives. It does not validate the parent-child relationships within the message tree. In the provided example, the message `23067407-327f-4167-bac6-5804080aed15` is an "orphan" message—it has no `parentId` key, and no other message lists it as a child. This process completes without any exceptions or warnings, as the backend logic does not currently validate the internal consistency of the chat tree. 2. **The Consequence:** When the frontend fetches this chat, its rendering logic receives an inconsistent state. It may, for example, iterate over one list of messages while trying to look up relationships in a different, out-of-sync map. When it encounters an inconsistency like the orphan message, the logic to determine the next message to render or to build the conversational tree can enter an unrecoverable state. This results in a logical deadlock or an infinite loop, which prevents the rendering process from ever completing, causing the persistent loading indicator. ### Actual Behavior The application hangs indefinitely on a loading spinner. **A critical diagnostic detail is that this failure is silent.** No errors are generated in the browser's developer console, and **no relevant warnings or errors appear in the Open-WebUI backend logs** during the import or subsequent access of the chat. This points to a logical deadlock in the frontend rendering process, triggered by data that was silently accepted as "valid" by the backend. ### Steps to Reproduce 1. Introduce a structurally inconsistent chat object into the database, for example, by using the "Import Chat" feature with the malformed JSON provided below. 2. The import process will appear to succeed, as no validation is performed on the chat's internal structure. 3. Attempt to open and view the newly imported chat from the chat list. ### Example of Malformed Data to Reproduce the Bug The following JSON data, with its full content, reliably triggers the bug. The key structural flaws are: 1. The message `23067407-327f-4167-bac6-5804080aed15` is an "orphan" message, as it is missing the `parentId` key. 2. The top-level `messages` array is out of sync with the `history.messages` map (it is missing the orphan message). ```json [ { "id": "8a3351f4-79c1-4731-8826-d5783944b0c2", "user_id": "fe7bbdce-2468-4ce4-aa02-00edd8c48e76", "title": "Fitur Applicant", "chat": { "id": "", "title": "Fitur Applicant", "models": ["claude-4-sonnet-latest"], "params": {}, "history": { "messages": { "2d16b51a-2ae5-433f-a8c9-dea4999a41e2": { "id": "2d16b51a-2ae5-433f-a8c9-dea4999a41e2", "parentId": null, "childrenIds": ["c3cd2a61-23cb-40d4-8898-8c6b72b2c155"], "role": "user", "content": "Anda adalah programmer/software engineer laravel 11 ahli, bertindaklah sebagaimana praktisi ahli bertindak. Anda juga harus teliti dan sangat berhati-hati. Selalu generate code terbaik yang clean dan readable menurut best practice. Anda juga harus berpikir straight to the poin dan tidak berhalusinasi. Dalam analisa kode, anda harus teliti dan pastikan tidak ada bagian yang luput dari inspeksi anda. Berikan penjelasan yang clear,detail,transparant.", "timestamp": 1750304687, "models": ["claude-4-sonnet-latest"] }, "c3cd2a61-23cb-40d4-8898-8c6b72b2c155": { "parentId": "2d16b51a-2ae5-433f-a8c9-dea4999a41e2", "id": "c3cd2a61-23cb-40d4-8898-8c6b72b2c155", "childrenIds": [], "role": "assistant", "content": "I understand you're looking for Laravel 11 expertise. I'm ready to help you with Laravel development questions, code reviews, best practices, and any technical challenges you're facing.\n\nAs a Laravel specialist, I can assist with:\n- Clean, readable code following Laravel conventions\n- Performance optimization\n- Security best practices\n- Database design and Eloquent relationships\n- API development\n- Testing strategies\n- Architecture decisions\n\nWhat specific Laravel 11 task or problem would you like help with today? Please share your code, requirements, or questions and I'll provide detailed, practical solutions.", "model": "claude-4-sonnet-latest", "modelName": "Claude 4 Sonnet Exp", "modelIdx": 0, "timestamp": 1750304687, "lastSentence": "As a Laravel specialist, I can assist with:\nClean, readable code following Laravel conventions\nPerformance optimization\nSecurity best practices\nDatabase design and Eloquent relationships\nAPI development\nTesting strategies\nArchitecture decisions\nWhat specific Laravel 11 task or problem would you like help with today?", "usage": { "prompt_tokens": 508, "completion_tokens": 125, "total_tokens": 633, "prompt_tokens_details": { "cached_tokens": 0, "cache_creation_input_tokens": 0 } }, "done": true, "followUps": [ "How can I optimize Eloquent query performance in Laravel 11 for large datasets?", "What's the best approach to implement multi-tenancy in a Laravel 11 application?", "Can you guide me on using Laravel 11's new Blade features effectively?", "How should I structure API resources for a RESTful Laravel 11 backend?", "What are the latest security practices for Laravel 11 authentication systems?" ] }, "23067407-327f-4167-bac6-5804080aed15": { "model": "claude-4-sonnet-latest", "content": "I'm ready to review your form.blade.php code. However, I don't see the actual code content in your message. Could you please share the code from your form.blade.php file so I can analyze it and provide detailed feedback?\n\nOnce you share the code, I'll examine it for:\n- Laravel best practices compliance\n- Security considerations (CSRF protection, validation, etc.)\n- Code structure and readability\n- Potential improvements\n- Any issues that need attention\n\nPlease paste your form.blade.php code and I'll give you a thorough analysis.", "followUps": [ "Could you check if my CSRF protection is implemented correctly in the form?", "How can I validate the form inputs in the controller using Laravel best practices?", "What are some tips to improve the readability and structure of my Blade form code?", "Are there any security vulnerabilities I should be aware of when handling form submissions in Laravel?", "Should I be using FormRequest classes for validation, and how do I set them up?" ] } }, "currentId": "23067407-327f-4167-bac6-5804080aed15" }, "messages": [ { "id": "2d16b51a-2ae5-433f-a8c9-dea4999a41e2", "parentId": null, "childrenIds": ["c3cd2a61-23cb-40d4-8898-8c6b72b2c155"], "role": "user", "content": "Anda adalah programmer/software engineer laravel 11 ahli, bertindaklah sebagaimana praktisi ahli bertindak. Anda juga harus teliti dan sangat berhati-hati. Selalu generate code terbaik yang clean dan readable menurut best practice. Anda juga harus berpikir straight to the poin dan tidak berhalusinasi. Dalam analisa kode, anda harus teliti dan pastikan tidak ada bagian yang luput dari inspeksi anda. Berikan penjelasan yang clear,detail,transparant.", "timestamp": 1750304687, "models": ["claude-4-sonnet-latest"] }, { "parentId": "2d16b51a-2ae5-433f-a8c9-dea4999a41e2", "id": "c3cd2a61-23cb-40d4-8898-8c6b72b2c155", "childrenIds": [], "role": "assistant", "content": "I understand you're looking for Laravel 11 expertise. I'm ready to help you with Laravel development questions, code reviews, best practices, and any technical challenges you're facing.\n\nAs a Laravel specialist, I can assist with:\n- Clean, readable code following Laravel conventions\n- Performance optimization\n- Security best practices\n- Database design and Eloquent relationships\n- API development\n- Testing strategies\n- Architecture decisions\n\nWhat specific Laravel 11 task or problem would you like help with today? Please share your code, requirements, or questions and I'll provide detailed, practical solutions.", "model": "claude-4-sonnet-latest", "modelName": "Claude 4 Sonnet Exp", "modelIdx": 0, "timestamp": 1750304687, "lastSentence": "As a Laravel specialist, I can assist with:\nClean, readable code following Laravel conventions\nPerformance optimization\nSecurity best practices\nDatabase design and Eloquent relationships\nAPI development\nTesting strategies\nArchitecture decisions\nWhat specific Laravel 11 task or problem would you like help with today?", "usage": { "prompt_tokens": 508, "completion_tokens": 125, "total_tokens": 633, "prompt_tokens_details": { "cached_tokens": 0, "cache_creation_input_tokens": 0 } }, "done": true, "followUps": [ "How can I optimize Eloquent query performance in Laravel 11 for large datasets?", "What's the best approach to implement multi-tenancy in a Laravel 11 application?", "Can you guide me on using Laravel 11's new Blade features effectively?", "How should I structure API resources for a RESTful Laravel 11 backend?", "What are the latest security practices for Laravel 11 authentication systems?" ] } ], "tags": [], "timestamp": 1750304687862, "files": [] }, "updated_at": 1750307488, "created_at": 1750304687, "share_id": null, "archived": false, "pinned": false, "meta": {}, "folder_id": null } ] ``` ### Screenshots ![Image](https://github.com/user-attachments/assets/b645014c-2539-4bcc-8514-fd912a33da53) ### Additional Information This bug was identified through a detailed debugging process that revealed several key insights which may be helpful for the development team: 1. **Specific Nature of Data Corruption:** The issue was traced back to a specific type of structural inconsistency in the chat's JSON data. The primary flaw was an "orphan" message object that completely lacked a `parentId` key, effectively detaching it from the conversational tree. This was compounded by the top-level `messages` array being out of sync with the `history.messages` map, as it did not contain the orphan message. 2. **Frontend Failure Mode is a Logical Deadlock, Not a Crash:** A crucial observation is that this issue **does not produce any errors in the browser's developer console**. This indicates the problem is not a simple runtime `TypeError` from accessing an `undefined` property. Instead, it suggests the frontend's rendering logic enters an unrecoverable state—likely an infinite loop or a state management deadlock—when it tries to process the inconsistent message tree. It cannot determine the correct sequence of messages to render, and thus hangs.
GiteaMirror added the bug label 2025-11-11 16:26:07 -06:00
Author
Owner

@usrlocalben commented on GitHub (Aug 10, 2025):

Related to #11536

@usrlocalben commented on GitHub (Aug 10, 2025): Related to #11536
Author
Owner

@usrlocalben commented on GitHub (Aug 10, 2025):

Users of llama-swap may get corrupted chats due to the way it construes backend errors as API messages.

Example:

...
"messages": {
  {
    ...prior messages...
    "99999999-9999-9999-9999-999999999999": {
      "parentId": "...",
      "id": "99999999-9999-9999-9999-999999999999",
      "childrenIds": [],
      "role": "assistant",
      "content": "Last good message",
      "model": "...",
      "modelName": "...",
      "modelIdx": 0,
      "timestamp": 17999999999,
      "done": true
    },
    "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa": {
      "error": {
        "content": "502: unexpected EOF\n"
      }
    }
  },
  "currentId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
}
...

This gives the Loading... spinner in chat UI despite successful retrieval at all other levels (no errors in console, no network errors, no noise on server logs etc.)

edit: I may have been a bit to hasty to link it to llama-swap. Glancing over the code there I don't see what I expect to wrt. to the error block, so it may have been caused by open-webui itself.

@usrlocalben commented on GitHub (Aug 10, 2025): Users of [llama-swap](https://github.com/mostlygeek/llama-swap) may get corrupted chats ~~due to the way it construes backend errors as API messages~~. Example: ```json ... "messages": { { ...prior messages... "99999999-9999-9999-9999-999999999999": { "parentId": "...", "id": "99999999-9999-9999-9999-999999999999", "childrenIds": [], "role": "assistant", "content": "Last good message", "model": "...", "modelName": "...", "modelIdx": 0, "timestamp": 17999999999, "done": true }, "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa": { "error": { "content": "502: unexpected EOF\n" } } }, "currentId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa" } ... ``` This gives the _Loading..._ spinner in chat UI despite successful retrieval at all other levels (no errors in console, no network errors, no noise on server logs etc.) edit: I may have been a bit to hasty to link it to llama-swap. Glancing over the code there I don't see what I expect to wrt. to the error block, so it may have been caused by open-webui itself.
Author
Owner

@YifengChenGeotab commented on GitHub (Sep 12, 2025):

I have encountered this another example of corrupted chat that can lead to this kind of silent failure and frontend deadlock. Hope someone will take a look at this bug since it has been months. @tjbck

`.history.messages[]:

"xxxxx-xxxxxx": {
"content": "......"
}`
however a normal message should look like this:
"yyy-yyyyyyy": {
"parentId": "zzz-zzzzzz",
"id": "...",
"childrenIds": [],
"role": "assistant",
"content": "...",
"model": "gpt-5",
"modelName": "GPT 5",
"modelIdx": 1,
"userContext": null,
"timestamp": 1756845175,
"lastSentence": "...",
"done": true
}

Image

@YifengChenGeotab commented on GitHub (Sep 12, 2025): I have encountered this another example of corrupted chat that can lead to this kind of silent failure and frontend deadlock. Hope someone will take a look at this bug since it has been months. @tjbck `.history.messages[]: "xxxxx-xxxxxx": { "content": "......" }` however a normal message should look like this: "yyy-yyyyyyy": { "parentId": "zzz-zzzzzz", "id": "...", "childrenIds": [], "role": "assistant", "content": "...", "model": "gpt-5", "modelName": "GPT 5", "modelIdx": 1, "userContext": null, "timestamp": 1756845175, "lastSentence": "...", "done": true } ![Image](https://github.com/user-attachments/assets/d7cf6e5f-1ec0-4119-9b92-5a1308bfcf6d)
Author
Owner

@DaRacci commented on GitHub (Sep 25, 2025):

I'm experiencing the same, I have this happen seemingly at random maybe once a week; Restarting the webserver seems to fix this but its very annoying.

Similarly I've found that having a user configured mcpo server which is unreachable can also cause this.

@DaRacci commented on GitHub (Sep 25, 2025): I'm experiencing the same, I have this happen seemingly at random maybe once a week; Restarting the webserver seems to fix this but its very annoying. Similarly I've found that having a user configured mcpo server which is unreachable can also cause this.
Author
Owner

@rgaricano commented on GitHub (Sep 25, 2025):

The basic structural checks but is quite limited, and as implement a full validation is "delicated",
I made a Chat Integrity Checker for help in managing this issues. It can be used for check & repair chat history. It have dry run config valve (to check without make changes) and debug level.

2 versions, as action function and as tool.

As I made for testing I added log entry for all chat processed, maybe the logging could be excesive.

Action Function: Check_Chats_Action_Function.py

Tool:

        """
        Check and repair chat structural integrity.

        :param chat_id: Specific chat ID to check (optional, if not provided checks all user chats)
        :param skip: Number of chats to skip for pagination (default: 0)
        :return: Summary report of the integrity check
        """

Valves:

        check_own_chats_only: bool = Field(
            default=True,
            description="If true, only check chats owned by the current user.",
        )
        dry_run: bool = Field(
            default=True, description="If true, only report issues without fixing them."
        )
        max_chats_per_run: int = Field(
            default=50, description="Maximum number of chats to process in one run."
        )
        log_level: Literal["DEBUG", "INFO", "WARNING", "ERROR"] = Field(
            default="INFO", description="Logging level for the function operations."
        )

v0.1.1 Edited, fixed some minor issue and added emitters:
Check_Chats_Tool.py

v0.1.2 Added param skip in tool (for processing chats starting at skip number )
(e.g. use Check Chats tool skip 200 )
Check_Chats_Tool_v0.1.2.py

v0.1.3 Added UserValves for easier config.
Check_Chats_Tool_v0.1.3.py

Example:
I check the chats with dry run and I detect a wrong one:

Image

I ask for check only this chat:

Image

I test it and efffectively it fails...loading

Image

I change the dry run valve (for make changes) & I ask for check and fix only this chat

Image

Image

Now I test the chat again... Fixed, I can see it correctly!

Image

@rgaricano commented on GitHub (Sep 25, 2025): The basic structural checks but is quite limited, and as implement a full validation is "delicated", I made a Chat Integrity Checker for help in managing this issues. It can be used for check & repair chat history. It have dry run config valve (to check without make changes) and debug level. 2 versions, as action function and as tool. As I made for testing I added log entry for all chat processed, maybe the logging could be excesive. Action Function: [Check_Chats_Action_Function.py](https://github.com/user-attachments/files/22534428/Check_Chats_Action_Function.py) Tool: ``` """ Check and repair chat structural integrity. :param chat_id: Specific chat ID to check (optional, if not provided checks all user chats) :param skip: Number of chats to skip for pagination (default: 0) :return: Summary report of the integrity check """ ``` Valves: ``` check_own_chats_only: bool = Field( default=True, description="If true, only check chats owned by the current user.", ) dry_run: bool = Field( default=True, description="If true, only report issues without fixing them." ) max_chats_per_run: int = Field( default=50, description="Maximum number of chats to process in one run." ) log_level: Literal["DEBUG", "INFO", "WARNING", "ERROR"] = Field( default="INFO", description="Logging level for the function operations." ) ``` v0.1.1 Edited, fixed some minor issue and added emitters: [Check_Chats_Tool.py](https://github.com/user-attachments/files/22537060/Check_Chats_Tool.py) v0.1.2 Added param skip in tool (for processing chats starting at _skip number_ ) (e.g. `use Check Chats tool skip 200 `) [Check_Chats_Tool_v0.1.2.py](https://github.com/user-attachments/files/22539905/Check_Chats_Tool_v0.1.2.py) v0.1.3 Added UserValves for easier config. [Check_Chats_Tool_v0.1.3.py](https://github.com/user-attachments/files/22549218/Check_Chats_Tool_v0.1.3.py) Example: I check the chats with dry run and I detect a wrong one: ![Image](https://github.com/user-attachments/assets/675779e1-a5f2-47e0-af1b-8cd7d2cac837) I ask for check only this chat: ![Image](https://github.com/user-attachments/assets/dbe1a399-4196-454f-9618-fa3570a5f19c) I test it and efffectively it fails...loading ![Image](https://github.com/user-attachments/assets/fb0d98ce-9663-46ab-931a-12d145f23fc8) I change the dry run valve (for make changes) & I ask for check and fix only this chat ![Image](https://github.com/user-attachments/assets/14d7f671-f787-410f-8d1c-f901bc74ee0e) ![Image](https://github.com/user-attachments/assets/ea82a30b-5d62-4622-a274-b58e87a26d29) Now I test the chat again... Fixed, I can see it correctly! ![Image](https://github.com/user-attachments/assets/8668691a-89a6-44d6-b892-ad9685bc5776)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#5606