danny-avila/LibreChat · warning · Error
File size is ${fileInfo.size} bytes. It exceeds the maximum
Error message
File size is ${fileInfo.size} bytes. It exceeds the maximum limit of ${maxFileSize} bytes. What it means
Thrown by importConversations when fs.stat(filepath).size exceeds maxFileSize (resolved once at module load via resolveImportMaxFileSize()). The guard prevents reading and JSON.parsing arbitrarily large uploads in the event loop. The limit is configurable through the resolver's env/source, so the threshold reflects deployment policy.
Source
Thrown at api/server/utils/import/importConversations.js:20
const { resolveImportMaxFileSize } = require('@librechat/api');
const { logger } = require('@librechat/data-schemas');
const { getImporter } = require('./importers');
const { createImportBatchBuilder } = require('./importBatchBuilder');
const maxFileSize = resolveImportMaxFileSize();
/**
* Job definition for importing a conversation.
* @param {{ filepath: string, requestUserId: string, userRole?: string, interfaceConfig?: object }} job
*/
const importConversations = async (job) => {
const { filepath, requestUserId, userRole, interfaceConfig } = job;
try {
logger.debug(`user: ${requestUserId} | Importing conversation(s) from file...`);
const fileInfo = await fs.stat(filepath);
if (fileInfo.size > maxFileSize) {
throw new Error(
`File size is ${fileInfo.size} bytes. It exceeds the maximum limit of ${maxFileSize} bytes.`,
);
}
const fileData = await fs.readFile(filepath, 'utf8');
const jsonData = JSON.parse(fileData);
const importer = getImporter(jsonData);
await importer(
jsonData,
requestUserId,
(userId) => createImportBatchBuilder(userId, interfaceConfig),
userRole,
);
logger.debug(`user: ${requestUserId} | Finished importing conversations`);
} catch (error) {
logger.error(`user: ${requestUserId} | Failed to import conversation: `, error);
throw error; // throw error all the way up so request does not return success
} finally {View on GitHub (pinned to 5ff282f900)
Solutions
- Split the export into smaller files below the limit before importing.
- Raise the configured max file size via the environment variable read by resolveImportMaxFileSize (set it and restart the worker).
- If the limit cannot be raised, prune attachments/large message content from the export first.
Example fix
// before: default limit too small for this export
// after: raise the limit in the environment before starting the API
// (set the variable read by resolveImportMaxFileSize, e.g.)
IMPORT_MAX_FILE_SIZE_BYTES=52428800 # 50 MiB
// then at the call site, validate early:
const stat = await fs.stat(filepath);
if (stat.size > maxFileSize) {
return res.status(413).json({ message: `Export too large: ${stat.size} bytes` });
} Defensive patterns
Strategy: validation
Validate before calling
const stat = await fs.stat(filepath);
if (stat.size > maxFileSize) {
throw new Error(`File size is ${stat.size} bytes. It exceeds the maximum limit of ${maxFileSize} bytes.`);
} Type guard
const isWithinImportLimit = (size, max) => typeof size === 'number' && size <= max;
Try / catch
try {
await importConversations(job);
} catch (err) {
if (err.message.includes('exceeds the maximum limit')) {
return res.status(413).json({ message: err.message });
}
throw err;
} Prevention
- Enforce a client-side size check before upload.
- Set the max-file-size env var to match real export sizes.
- Split large exports into multiple smaller files.
When it happens
Trigger: Uploading a conversation export larger than the configured limit; the limit being left at its default while exports grow; importing a long-running account history that accumulated many messages.
Common situations: Default limit too low for power users; env var controlling the limit not set in production; combining many conversations into one file.
Related errors
- No endpoint provided
- File size limit of ${fileSizeLimit / megabyte} MB exceeded f
- Unsupported file type
- Unsupported import type
- Invalid LibreChat file format
AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12).
Data as JSON: /api/errors/8d2513d9efe3f84b.
Report an issue: GitHub.