{"record":{"id":"df50e5da4616b1db","repo":"danny-avila/LibreChat","slug":"unsupported-import-type","errorCode":null,"errorMessage":"Unsupported import type","messagePattern":"Unsupported import type","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"api/server/utils/import/importers.js","lineNumber":29,"sourceCode":" *\n * @param {Object} jsonData - The JSON data to import.\n * @returns {Function} - The importer function.\n * @throws {Error} - If the import type is not supported.\n */\nfunction getImporter(jsonData) {\n  // For array-based formats (ChatGPT or Claude)\n  if (Array.isArray(jsonData)) {\n    // Claude format has chat_messages array in each conversation\n    if (jsonData.length > 0 && jsonData[0]?.chat_messages) {\n      logger.info('Importing Claude conversation');\n      return importClaudeConvo;\n    }\n    // ChatGPT format has mapping object in each conversation\n    if (jsonData.length === 0 || jsonData[0]?.mapping) {\n      logger.info('Importing ChatGPT conversation');\n      return importChatGptConvo;\n    }\n    throw new Error('Unsupported import type');\n  }\n\n  // For ChatbotUI\n  if (jsonData.version && Array.isArray(jsonData.history)) {\n    logger.info('Importing ChatbotUI conversation');\n    return importChatBotUiConvo;\n  }\n\n  // For LibreChat\n  if (jsonData.conversationId && (jsonData.messagesTree || jsonData.messages)) {\n    logger.info('Importing LibreChat conversation');\n    return importLibreChatConvo;\n  }\n\n  throw new Error('Unsupported import type');\n}\n\n/**","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/utils/import/importers.js#L11-L47","documentation":"Thrown by getImporter (utils/import/importers.js) for array-shaped JSON that is neither Claude format (first element has chat_messages) nor ChatGPT format (first element has mapping, or the array is empty). The detector recognizes only those two array schemas, so any other array structure is rejected before an importer is selected.","triggerScenarios":"Importing an array of objects whose elements lack both chat_messages and mapping keys; an array produced by a different export tool; a partially-truncated export where the first object is missing its distinguishing field.","commonSituations":"Third-party export format not yet supported; malformed/partial download; an array wrapped one level too deep (e.g. { data: [...] } instead of [...]).","solutions":["Confirm the file is a Claude or ChatGPT export by checking that the first array element has chat_messages (Claude) or mapping (ChatGPT).","If the data is actually an object export (ChatbotUI/LibreChat), unwrap it so getImporter receives the object, not an array.","Transform the unsupported array into one of the supported schemas, or add a custom importer and register it in getImporter."],"exampleFix":"// before: array of bare {text} objects -> throws\n// after: reshape into ChatGPT-like mapping, or import as LibreChat object\nconst reshaped = {\n  conversationId: convo.id,\n  messages: originalArray.map(m => ({ ...m })),\n};\nconst importer = getImporter(reshaped);","handlingStrategy":"validation","validationCode":"function detectArrayFormat(jsonData) {\n  if (!Array.isArray(jsonData)) return null;\n  if (jsonData.length > 0 && jsonData[0]?.chat_messages) return 'claude';\n  if (jsonData.length === 0 || jsonData[0]?.mapping) return 'chatgpt';\n  return null;\n}\nif (!detectArrayFormat(jsonData)) throw new Error('Unsupported import type');","typeGuard":"const isClaudeExport = (a) => Array.isArray(a) && a.length > 0 && !!a[0]?.chat_messages;\nconst isChatGptExport = (a) => Array.isArray(a) && (a.length === 0 || !!a[0]?.mapping);","tryCatchPattern":"try {\n  const importer = getImporter(jsonData);\n} catch (err) {\n  if (err.message === 'Unsupported import type') {\n    return res.status(400).json({ message: 'Unrecognized export format.' });\n  }\n  throw err;\n}","preventionTips":["Pre-validate the export shape before invoking getImporter.","Document the supported array schemas (Claude chat_messages, ChatGPT mapping) for users.","Unwrap nested arrays/objects so getImporter receives the canonical top-level shape."],"tags":["import","validation","format-detection"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}