Skip to content

Commit 1555252

Browse files
authored
fix: handle undefined model in createMessagePair function (open-webui#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.
1 parent de0cbb9 commit 1555252

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/lib/components/chat/Chat.svelte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,6 +1282,11 @@
12821282
const modelId = selectedModels[0];
12831283
const model = $models.filter((m) => m.id === modelId).at(0);
12841284
1285+
if (!model) {
1286+
toast.error($i18n.t('Model not found'));
1287+
return;
1288+
}
1289+
12851290
const messages = createMessagesList(history, history.currentId);
12861291
const parentMessage = messages.length !== 0 ? messages.at(-1) : null;
12871292

0 commit comments

Comments
 (0)