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
This commit is contained in:
lawrence3699 2026-04-09 18:46:50 +10:00
parent cb0fd6ed41
commit d26050081c
No known key found for this signature in database

View file

@ -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)) {