From 01eedd36bc899847db00f0e2b413d6f2d0f65ccb Mon Sep 17 00:00:00 2001 From: Dave Date: Thu, 29 May 2025 06:19:13 +0200 Subject: [PATCH] Handles undefined message case in message list creation Prevents potential errors by returning an empty list if the specified message ID does not exist in the history. This enhancement ensures robustness in scenarios where a message ID may be missing, avoiding further processing and potential exceptions. --- src/lib/utils/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index fea87e2d5..2e9785514 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -1225,6 +1225,9 @@ export const createMessagesList = (history, messageId) => { } const message = history.messages[messageId]; + if (message === undefined) { + return []; + } if (message?.parentId) { return [...createMessagesList(history, message.parentId), message]; } else {