From 1555252c4a60cbf0be96d4725ea25b42e101cdf9 Mon Sep 17 00:00:00 2001 From: G30 <50341825+silentoplayz@users.noreply.github.com> Date: Thu, 15 Jan 2026 01:43:25 -0500 Subject: [PATCH] fix: handle undefined model in createMessagePair function (#20663) - Add a null check when looking up model to prevent JavaScript error when trying to add a message pair in a chat with an invalid/corrupt model ID. --- src/lib/components/chat/Chat.svelte | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index ff41dfe472..d7341257f2 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -1282,6 +1282,11 @@ const modelId = selectedModels[0]; const model = $models.filter((m) => m.id === modelId).at(0); + if (!model) { + toast.error($i18n.t('Model not found')); + return; + } + const messages = createMessagesList(history, history.currentId); const parentMessage = messages.length !== 0 ? messages.at(-1) : null;