Mintplex-Labs/anything-llm · error · Error
Unsupported export type: ${type}
Error message
Unsupported export type: ${type} What it means
Thrown by sendChatHistoryFile() in its switch default when `type` is not one of pdf, markdown, plaintext, json, html. This is the file-rendering pipeline (distinct from the data export in convertTo.js): it produces a downloadable rendered artifact. An unknown type has no renderer, so the request is rejected. The valid values are exported as validExportTypes.
Source
Thrown at server/utils/chats/exportChatToFile.js:254
return response.send(Buffer.from(md, "utf-8"));
}
case "plaintext": {
const txt = chatHistoryToPlainText(convertToChatHistory(chats), meta);
response.setHeader("Content-Type", "text/plain");
return response.send(Buffer.from(txt, "utf-8"));
}
case "json": {
const json = chatHistoryToJSON(convertToChatHistory(chats), meta);
response.setHeader("Content-Type", "application/json");
return response.send(Buffer.from(json, "utf-8"));
}
case "html": {
const html = chatHistoryToHTML(convertToChatHistory(chats), meta);
response.setHeader("Content-Type", "text/html");
return response.send(Buffer.from(html, "utf-8"));
}
default:
throw new Error(`Unsupported export type: ${type}`);
}
}
module.exports = { sendChatHistoryFile, validExportTypes };
View on GitHub (pinned to 526360e320)
Solutions
- Use one of the rendered types: 'pdf', 'markdown', 'plaintext', 'json', 'html'.
- Validate `type` against the exported validExportTypes array before calling sendChatHistoryFile.
- Route csv/jsonl/jsonAlpaca exports through exportChatsAsType (convertTo.js), not this function.
- Return 400 with the allowed list when the type is unknown.
Example fix
// before
await sendChatHistoryFile(res, chats, meta, type); // type='csv' -> throws
// after
const validExportTypes = ['pdf','markdown','plaintext','json','html'];
if (!validExportTypes.includes(type))
return res.status(400).json({ error: `type must be one of ${validExportTypes.join(',')}` });
await sendChatHistoryFile(res, chats, meta, type); Defensive patterns
Strategy: validation
Validate before calling
const { validExportTypes } = require('../utils/chats/exportChatToFile');
if (!validExportTypes.includes(type))
return res.status(400).json({ error: `type must be one of ${validExportTypes.join(',')}` }); Type guard
type HistoryFileType = 'pdf'|'markdown'|'plaintext'|'json'|'html';
function isHistoryFileType(v): v is HistoryFileType {
return ['pdf','markdown','plaintext','json','html'].includes(v);
} Try / catch
try {
await sendChatHistoryFile(res, chats, meta, type);
} catch (e) {
if (e.message.startsWith('Unsupported export type:')) return res.status(400).json({ error: e.message });
throw e;
} Prevention
- Reuse the exported validExportTypes list rather than hardcoding.
- Route csv/jsonl/jsonAlpaca through exportChatsAsType, not sendChatHistoryFile.
- Validate the route param against the constant before calling.
When it happens
Trigger: A download route like /chat-history/:type where :type is 'docx', 'csv', 'jsonl', or 'JSON'. Note 'csv'/'jsonl' belong to the data-export pipeline, not this renderer, so passing them here throws.
Common situations: Mixing up the two export systems; an old bookmarked URL with a now-unsupported type; a frontend bug sending the data-export format to the file-render endpoint.
Related errors
- Invalid export type: ${format}
- Invalid chat type: ${chatType}
- Bad Request
- Type "${type}" is not a valid type to sync.
- Invalid link provided
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/517062c8c994e078.
Report an issue: GitHub.