[PR #20264] [MERGED] fix: prevent crash when regenerating message with missing parent #48575

Closed
opened 2026-04-30 00:35:37 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/20264
Author: @silentoplayz
Created: 12/30/2025
Status: Merged
Merged: 12/30/2025
Merged by: @tjbck

Base: devHead: fix/chat-regenerate-crash


📝 Commits (1)

  • 074bba4 fix: prevent crash when regenerating message with missing parent

📊 Changes

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

View changed files

📝 src/lib/components/chat/Chat.svelte (+5 -0)

📄 Description

Pull Request Checklist

Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request.

This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR.

Before submitting, make sure you've checked the following:

  • Target branch: Verify that the pull request targets the dev branch. Not targeting the dev branch will lead to immediate closure of the PR.
  • Description: Provide a concise description of the changes made in this pull request down below.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Documentation: If necessary, update relevant documentation Open WebUI Docs like environment variables, the tutorials, or other documentation sources.
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Perform manual tests to verify the implemented fix/feature works as intended AND does not break any other functionality. Take this as an opportunity to make screenshots of the feature/fix and include it in the PR description.
  • Agentic AI Code: Confirm this Pull Request is not written by any AI Agent or has at least gone through additional human review AND manual testing. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR.
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Title Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • fix: Bug fix or error correction

Changelog Entry

Description

This PR fixes a critical bug where the application would crash when attempting to regenerate a message that has a missing or corrupted parent message ID. Instead of crashing, the application now gracefully handles this state by displaying a toast error message to the user.

Fixed

  • Fixed a TypeError crash in Chat.svelte when regenerating a response for a message with an invalid or missing parent.

This PR solves the following browser console error from being thrown:

Uncaught (in promise) TypeError: can't access property "id", userMessage is undefined
    regenerateResponse Chat.svelte:2147
    onRegenerate ResponseMessage.svelte:1348
    click RegenerateMenu.svelte:83
    createEventDispatcher index-client.js:178
    createDispatcher events.js:8
    apply events.js:337
    alternate bits-ui.js:22130
    target_handler events.js:61
    without_reactive_context shared.js:44
    target_handler events.js:60
    dispatchMeltEvent event.js:43
    withMelt event.js:48
    addMeltEventListener event.js:25
    addMeltEventListener event.js:25
    action create.js:300
    alternate bits-ui.js:22126
    payload actions.js:15
    untrack runtime.js:747
    action actions.js:15
    update_reaction runtime.js:297
    update_effect runtime.js:477
    flush_queued_effects batch.js:667
    process batch.js:196
    flush_effects batch.js:622
    flush batch.js:314
    ensure batch.js:502
    run_all utils.js:45
    run_micro_tasks task.js:10
    queue_micro_task task.js:28
    queue_micro_task task.js:19
    enqueue batch.js:512
    ensure batch.js:496
    internal_set sources.js:184
    set sources.js:163
    set show RegenerateMenu.svelte:56
    prop props.js:372
    set open Dropdown.svelte:18
    prop props.js:372
    onOpenChange menu.svelte:37
    update overridable.js:9
    update2 index.js:70
    update overridable.js:5
    handleOpen create.js:1034
    unsub create.js:199
    handlerWithMelt event.js:23
    withMelt event.js:51
    addMeltEventListener event.js:25
    addMeltEventListener event.js:25
    action create.js:194
    alternate bits-ui.js:32384
    payload actions.js:15
    untrack runtime.js:747
    action actions.js:15
    update_reaction runtime.js:297
    update_effect runtime.js:477
    flush_queued_effects batch.js:667
    process batch.js:196
    flush_effects batch.js:622
Chat.svelte:2147:31

Additional Information

The issue was caused by regenerateResponse attempting to access properties of userMessage (the parent message) without verifying if userMessage existed in the chat history. This could happen if the chat history was corrupted or if there were synchronization issues. The fix adds a null check for userMessage.

Screenshots or Videos

image image

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.


🔄 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/20264 **Author:** [@silentoplayz](https://github.com/silentoplayz) **Created:** 12/30/2025 **Status:** ✅ Merged **Merged:** 12/30/2025 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `fix/chat-regenerate-crash` --- ### 📝 Commits (1) - [`074bba4`](https://github.com/open-webui/open-webui/commit/074bba4bd9d7a00bb59893a6d31ebe0d4934a5a1) fix: prevent crash when regenerating message with missing parent ### 📊 Changes **1 file changed** (+5 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/chat/Chat.svelte` (+5 -0) </details> ### 📄 Description # Pull Request Checklist ### Note to first-time contributors: Please open a discussion post in [Discussions](https://github.com/open-webui/open-webui/discussions) to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request. This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR. **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Verify that the pull request targets the `dev` branch. **Not targeting the `dev` branch will lead to immediate closure of the PR.** - [x] **Description:** Provide a concise description of the changes made in this pull request down below. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [x] **Documentation:** If necessary, update relevant documentation [Open WebUI Docs](https://github.com/open-webui/docs) like environment variables, the tutorials, or other documentation sources. - [x] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Perform manual tests to **verify the implemented fix/feature works as intended AND does not break any other functionality**. Take this as an opportunity to **make screenshots of the feature/fix and include it in the PR description**. - [x] **Agentic AI Code:** Confirm this Pull Request is **not written by any AI Agent** or has at least **gone through additional human review AND manual testing**. If any AI Agent is the co-author of this PR, it may lead to immediate closure of the PR. - [x] **Code review:** Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards? - [x] **Title Prefix:** To clearly categorize this pull request, prefix the pull request title using one of the following: - **fix**: Bug fix or error correction # Changelog Entry ### Description This PR fixes a critical bug where the application would crash when attempting to regenerate a message that has a missing or corrupted parent message ID. Instead of crashing, the application now gracefully handles this state by displaying a toast error message to the user. ### Fixed - Fixed a `TypeError` crash in `Chat.svelte` when regenerating a response for a message with an invalid or missing parent. This PR solves the following browser console error from being thrown: ```js Uncaught (in promise) TypeError: can't access property "id", userMessage is undefined regenerateResponse Chat.svelte:2147 onRegenerate ResponseMessage.svelte:1348 click RegenerateMenu.svelte:83 createEventDispatcher index-client.js:178 createDispatcher events.js:8 apply events.js:337 alternate bits-ui.js:22130 target_handler events.js:61 without_reactive_context shared.js:44 target_handler events.js:60 dispatchMeltEvent event.js:43 withMelt event.js:48 addMeltEventListener event.js:25 addMeltEventListener event.js:25 action create.js:300 alternate bits-ui.js:22126 payload actions.js:15 untrack runtime.js:747 action actions.js:15 update_reaction runtime.js:297 update_effect runtime.js:477 flush_queued_effects batch.js:667 process batch.js:196 flush_effects batch.js:622 flush batch.js:314 ensure batch.js:502 run_all utils.js:45 run_micro_tasks task.js:10 queue_micro_task task.js:28 queue_micro_task task.js:19 enqueue batch.js:512 ensure batch.js:496 internal_set sources.js:184 set sources.js:163 set show RegenerateMenu.svelte:56 prop props.js:372 set open Dropdown.svelte:18 prop props.js:372 onOpenChange menu.svelte:37 update overridable.js:9 update2 index.js:70 update overridable.js:5 handleOpen create.js:1034 unsub create.js:199 handlerWithMelt event.js:23 withMelt event.js:51 addMeltEventListener event.js:25 addMeltEventListener event.js:25 action create.js:194 alternate bits-ui.js:32384 payload actions.js:15 untrack runtime.js:747 action actions.js:15 update_reaction runtime.js:297 update_effect runtime.js:477 flush_queued_effects batch.js:667 process batch.js:196 flush_effects batch.js:622 Chat.svelte:2147:31 ``` --- ### Additional Information The issue was caused by `regenerateResponse` attempting to access properties of `userMessage` (the parent message) without verifying if `userMessage` existed in the chat history. This could happen if the chat history was corrupted or if there were synchronization issues. The fix adds a null check for `userMessage`. ### Screenshots or Videos <img width="2288" height="1270" alt="image" src="https://github.com/user-attachments/assets/2273beba-1d48-487e-beea-debc573df8ce" /> <img width="402" height="95" alt="image" src="https://github.com/user-attachments/assets/cfbfd177-54ee-4931-9871-135d96eb1977" /> ### 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. --- <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 00:35:37 -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#48575