{"record":{"id":"d6480a8ec503f9d8","repo":"danny-avila/LibreChat","slug":"all-files-in-batch-upload-failed","errorCode":null,"errorMessage":"All files in batch upload failed","messagePattern":"All files in batch upload failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/server/services/Files/Code/crud.js","lineNumber":258,"sourceCode":"    timeout: 120000,\n    maxContentLength: MAX_FILE_SIZE,\n    maxBodyLength: MAX_FILE_SIZE,\n  };\n\n  const response = await axios.post(`${baseURL}/upload/batch`, form, options);\n\n  /** @type {{ message: string; storage_session_id: string; files: Array<{ status: string; fileId?: string; filename: string; error?: string }>; succeeded: number; failed: number }} */\n  const result = response.data;\n  if (\n    !result ||\n    typeof result !== 'object' ||\n    !result.storage_session_id ||\n    !Array.isArray(result.files)\n  ) {\n    throw new Error(`Unexpected batch upload response: ${JSON.stringify(result).slice(0, 200)}`);\n  }\n  if (result.message === 'error') {\n    throw new Error('All files in batch upload failed');\n  }\n\n  if (result.failed > 0) {\n    const failedNames = result.files\n      .filter((f) => f.status === 'error')\n      .map((f) => `${f.filename}: ${f.error || 'unknown'}`)\n      .join(', ');\n    logger.warn(`[batchUploadCodeEnvFiles] ${result.failed} file(s) failed: ${failedNames}`);\n  }\n\n  const successFiles = result.files\n    .filter((f) => f.status === 'success' && f.fileId)\n    .map((f) => ({ fileId: f.fileId, filename: f.filename }));\n\n  return { storage_session_id: result.storage_session_id, files: successFiles };\n}\n\nmodule.exports = {","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Files/Code/crud.js#L240-L276","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await batchUploadCodeEnvFiles(params);\n} catch (err) {\n  if (/All files in batch upload failed/.test(err.message)) {\n    // isolate per-file failures\n    return Promise.allSettled(files.map((f) => uploadCodeEnvFile({ ...params, file: f })));\n  }\n  throw err;\n}","preventionTips":["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."],"tags":["code-env","upload","batch","retry"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}