mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #22853] [CLOSED] fix(modal): resolve ReferenceError for idx in InputVariablesModal #26888
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/22853
Author: @futhgar
Created: 3/19/2026
Status: ❌ Closed
Base:
dev← Head:fix/input-variables-modal-idx📝 Commits (1)
93d5c47fix(modal): resolve ReferenceError for idx in InputVariablesModal📊 Changes
1 file changed (+24 additions, -16 deletions)
View changed files
📝
src/lib/components/chat/MessageInput/InputVariablesModal.svelte(+24 -16)📄 Description
Pull Request Checklist
devbranch.{@const}derived is no longer generated. Full build passes.fixChangelog Entry
Description
When selecting a custom prompt with template variables (e.g.
{{variable_name}}), the Input Variables modal threwReferenceError: idx is not definedand displayed an infinite loading spinner instead of the input fields.The root cause is a
{@const}declaration with rest-spread destructuring ({@const { type, ...variableAttributes } = variables[variable] ?? {}}) inside an{#each}block. In Svelte 5's legacy reactivity mode, this pattern creates a$.derived_safe_equal()that interferes with the each-block index variable (idx) scoping when combined with{...variableAttributes}spread on elements that also referenceidxfor theiridattribute.The fix moves the rest-spread destructuring from an inline
{@const}to a helper function (getVariableAttributes) in the<script>section. This avoids the problematic Svelte 5 compiled derived while preserving the same attribute-spreading behavior.Added
getVariableAttributes()helper function that extracts all properties excepttypefrom a variable definitionFixed
ReferenceError: idx is not definedinInputVariablesModal.sveltewhen opening the Input Variables modal (Fixes #22748)Additional Information
{@const}with rest-spread destructuring inside{#each}blocks is a known problematic pattern in Svelte 5 legacy mode. Moving the destructuring to a script-level function avoids the compiler generating a derived that interferes with the each-block index variable scoping.vite buildpasses successfully with the fix applied.Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.