danny-avila/LibreChat · error · Error
Empty file uploaded
Error message
Empty file uploaded
What it means
filterFile() throws this at process.js:1328 when multer populated req.file but file.size === 0. The guard exists because a zero-byte file would otherwise be saved, referenced by a file_id, and silently corrupt later processing (image resize, RAG ingest). It is an early, explicit failure for a degenerate multipart upload.
Source
Thrown at api/server/services/Files/process.js:1328
* @param {number} [params.req.width]
* @param {number} [params.req.height]
* @param {number} [params.req.version]
* @param {boolean} [params.image] - Whether the file expected is an image.
* @param {boolean} [params.isAvatar] - Whether the file expected is a user or entity avatar.
* @returns {void}
*
* @throws {Error} If a file exception is caught (invalid file size or type, lack of metadata).
*/
function filterFile({ req, image, isAvatar }) {
const { file } = req;
const { endpoint, endpointType, file_id, width, height } = req.body;
if (!file_id && !isAvatar) {
throw new Error('No file_id provided');
}
if (file.size === 0) {
throw new Error('Empty file uploaded');
}
/* parse to validate api call, throws error on fail */
if (!isAvatar) {
isUUID.parse(file_id);
}
if (!endpoint && !isAvatar) {
throw new Error('No endpoint provided');
}
const appConfig = req.config;
const fileConfig = mergeFileConfig(appConfig.fileConfig);
const endpointFileConfig = getEndpointFileConfig({
endpoint,
fileConfig,
endpointType,View on GitHub (pinned to 5ff282f900)
Solutions
- On the client, reject files with size === 0 before constructing the FormData.
- Inspect the raw multipart payload (Network tab) to confirm the file part carries bytes.
- If using a streaming source, ensure the stream has ended and emitted data before appending.
Example fix
// before
form.append('file', new Blob([]), 'empty.txt');
// after
if (selectedFile.size === 0) { alert('File is empty'); return; }
form.append('file', selectedFile, selectedFile.name); Defensive patterns
Strategy: validation
Validate before calling
function isValidUploadFile(file) {
return !!file && typeof file.size === 'number' && file.size > 0;
} Type guard
const isNonEmptyFile = (f) => !!f && f.size > 0;
Prevention
- Reject size === 0 in the file picker before constructing FormData.
- Log selectedFile.size in dev builds to catch empty selections early.
When it happens
Trigger: A multipart upload whose file part has no content: the user picked a file then emptied it, a stream pipe closed before bytes flowed, or the client appended an empty Blob/File. Also seen when a proxy truncates the body.
Common situations: Drag-and-drop UI that lets a 0-byte file through. A frontend test that constructs FormData from an uninitialized Blob. Network middleware that strips the body under a size threshold.
Related errors
- No file_id provided
- No width provided
- No height provided
- Error uploading file: ${result.message}
- Unexpected batch upload response: ${JSON.stringify(result).s
AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12).
Data as JSON: /api/errors/a9dedf61cde19736.
Report an issue: GitHub.