danny-avila/LibreChat · error · Error
Unsupported import type
Error message
Unsupported import type
What it means
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.
Source
Thrown at api/server/utils/import/importers.js:29
*
* @param {Object} jsonData - The JSON data to import.
* @returns {Function} - The importer function.
* @throws {Error} - If the import type is not supported.
*/
function getImporter(jsonData) {
// For array-based formats (ChatGPT or Claude)
if (Array.isArray(jsonData)) {
// Claude format has chat_messages array in each conversation
if (jsonData.length > 0 && jsonData[0]?.chat_messages) {
logger.info('Importing Claude conversation');
return importClaudeConvo;
}
// ChatGPT format has mapping object in each conversation
if (jsonData.length === 0 || jsonData[0]?.mapping) {
logger.info('Importing ChatGPT conversation');
return importChatGptConvo;
}
throw new Error('Unsupported import type');
}
// For ChatbotUI
if (jsonData.version && Array.isArray(jsonData.history)) {
logger.info('Importing ChatbotUI conversation');
return importChatBotUiConvo;
}
// For LibreChat
if (jsonData.conversationId && (jsonData.messagesTree || jsonData.messages)) {
logger.info('Importing LibreChat conversation');
return importLibreChatConvo;
}
throw new Error('Unsupported import type');
}
/**View on GitHub (pinned to 5ff282f900)
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.
Example fix
// before: array of bare {text} objects -> throws
// after: reshape into ChatGPT-like mapping, or import as LibreChat object
const reshaped = {
conversationId: convo.id,
messages: originalArray.map(m => ({ ...m })),
};
const importer = getImporter(reshaped); Defensive patterns
Strategy: validation
Validate before calling
function detectArrayFormat(jsonData) {
if (!Array.isArray(jsonData)) return null;
if (jsonData.length > 0 && jsonData[0]?.chat_messages) return 'claude';
if (jsonData.length === 0 || jsonData[0]?.mapping) return 'chatgpt';
return null;
}
if (!detectArrayFormat(jsonData)) throw new Error('Unsupported import type'); Type guard
const isClaudeExport = (a) => Array.isArray(a) && a.length > 0 && !!a[0]?.chat_messages; const isChatGptExport = (a) => Array.isArray(a) && (a.length === 0 || !!a[0]?.mapping);
Try / catch
try {
const importer = getImporter(jsonData);
} catch (err) {
if (err.message === 'Unsupported import type') {
return res.status(400).json({ message: 'Unrecognized export format.' });
}
throw err;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: Third-party export format not yet supported; malformed/partial download; an array wrapped one level too deep (e.g. { data: [...] } instead of [...]).
Related errors
- Invalid LibreChat file format
- File size is ${fileInfo.size} bytes. It exceeds the maximum
- [${req.baseUrl}] Endpoint is required
- Text is required
- Error uploading file: ${result.message}
AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12).
Data as JSON: /api/errors/df50e5da4616b1db.
Report an issue: GitHub.