danny-avila/LibreChat · error
All files in batch upload failed
Error message
All files in batch upload failed
What it means
Thrown by batchUploadCodeEnvFiles (Code/crud.js) when codeapi returns a valid response with result.message === 'error', meaning every file in the batch failed. The response is well-formed; the upload itself was rejected wholesale.
Source
Thrown at api/server/services/Files/Code/crud.js:258
timeout: 120000,
maxContentLength: MAX_FILE_SIZE,
maxBodyLength: MAX_FILE_SIZE,
};
const response = await axios.post(`${baseURL}/upload/batch`, form, options);
/** @type {{ message: string; storage_session_id: string; files: Array<{ status: string; fileId?: string; filename: string; error?: string }>; succeeded: number; failed: number }} */
const result = response.data;
if (
!result ||
typeof result !== 'object' ||
!result.storage_session_id ||
!Array.isArray(result.files)
) {
throw new Error(`Unexpected batch upload response: ${JSON.stringify(result).slice(0, 200)}`);
}
if (result.message === 'error') {
throw new Error('All files in batch upload failed');
}
if (result.failed > 0) {
const failedNames = result.files
.filter((f) => f.status === 'error')
.map((f) => `${f.filename}: ${f.error || 'unknown'}`)
.join(', ');
logger.warn(`[batchUploadCodeEnvFiles] ${result.failed} file(s) failed: ${failedNames}`);
}
const successFiles = result.files
.filter((f) => f.status === 'success' && f.fileId)
.map((f) => ({ fileId: f.fileId, filename: f.filename }));
return { storage_session_id: result.storage_session_id, files: successFiles };
}
module.exports = {View on GitHub (pinned to 5ff282f900)
Solutions
- Retry the batch once — if transient, a second attempt may succeed.
- If retry fails, fall back to per-file uploads (uploadCodeEnvFile) to isolate which files are rejected and why.
- Check the code server logs for the per-file failure reasons (the batch response may not include them when message==='error').
- Validate file types/sizes client-side before assembling the batch.
Defensive patterns
Strategy: fallback
Try / catch
try {
await batchUploadCodeEnvFiles(params);
} catch (err) {
if (/All files in batch upload failed/.test(err.message)) {
// isolate per-file failures
return Promise.allSettled(files.map((f) => uploadCodeEnvFile({ ...params, file: f })));
}
throw err;
} Prevention
- Retry the batch once for transient server-side rejections.
- Fall back to per-file uploads to surface which files were rejected and why.
- Validate file types/sizes before assembling the batch.
When it happens
Trigger: All files in the batch hit a server-side rejection — e.g. none of the MIME types are accepted, the session is in a bad state, or a quota/enforcement rule blocked the whole batch.
Common situations: All attached files are of a type the code server rejects; the target session was revoked/expired; a server-side policy (size, count) rejected the batch; transient code server fault returned message:'error'.
Related errors
- Unexpected batch upload response: ${JSON.stringify(result).s
- Error uploading file: ${result.message}
- Error uploading code environment file: ${error.message}
- Error downloading code environment file stream: ${error.mess
- An error occurred during file deletion.
AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12).
Data as JSON: /api/errors/d6480a8ec503f9d8.
Report an issue: GitHub.