From d26050081c6b11782c242d5f838e595d9c6cd2f0 Mon Sep 17 00:00:00 2001 From: lawrence3699 Date: Thu, 9 Apr 2026 18:46:50 +1000 Subject: [PATCH] fix: handle ChatGPT exports containing folder/project metadata entries ChatGPT exports now include folder and project metadata entries in conversations.json that lack a 'mapping' key. When such an entry appeared first in the array, getImportOrigin() misidentified the export as 'webui' format, causing convertOpenAIChats() to never run and resulting in "Imported 0 Chats". - getImportOrigin: check if any item has 'mapping', not just _chats[0] - convertOpenAIChats: skip entries without 'mapping' before conversion Fixes #23505 --- src/lib/utils/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/utils/index.ts b/src/lib/utils/index.ts index c11c33ac33..40c5e216fb 100644 --- a/src/lib/utils/index.ts +++ b/src/lib/utils/index.ts @@ -677,7 +677,9 @@ export const calculateSHA256 = async (file) => { export const getImportOrigin = (_chats) => { // Check what external service chat imports are from - if ('mapping' in _chats[0]) { + // ChatGPT exports may include folder/project entries without 'mapping', + // so check all items rather than only _chats[0]. + if (_chats.some((chat) => chat != null && typeof chat === 'object' && 'mapping' in chat)) { return 'openai'; } return 'webui'; @@ -800,6 +802,11 @@ export const convertOpenAIChats = (_chats) => { const chats = []; let failed = 0; for (const convo of _chats) { + // Skip non-conversation entries (e.g. folder/project metadata) + if (!convo['mapping']) { + continue; + } + const chat = convertOpenAIMessages(convo); if (validateChat(chat)) {