{"record":{"id":"7c6fb3dc774ba7f1","repo":"danny-avila/LibreChat","slug":"error-uploading-file-result-message","errorCode":null,"errorMessage":"Error uploading file: ${result.message}","messagePattern":"Error uploading file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"api/server/services/Files/Code/crud.js","lineNumber":178,"sourceCode":"        ...form.getHeaders(),\n        'Content-Type': 'multipart/form-data',\n        'User-Agent': 'LibreChat/1.0',\n        'User-Id': req.user.id,\n        ...authHeaders,\n      },\n      httpAgent: codeServerHttpAgent,\n      httpsAgent: codeServerHttpsAgent,\n      timeout: 120000,\n      maxContentLength: MAX_FILE_SIZE,\n      maxBodyLength: MAX_FILE_SIZE,\n    };\n\n    const response = await axios.post(`${baseURL}/upload`, form, options);\n\n    /** @type {{ message: string; storage_session_id: string; files: Array<{ fileId: string; filename: string }> }} */\n    const result = response.data;\n    if (result.message !== 'success') {\n      throw new Error(`Error uploading file: ${result.message}`);\n    }\n\n    return {\n      storage_session_id: result.storage_session_id,\n      file_id: result.files[0].fileId,\n    };\n  } catch (error) {\n    throw new Error(\n      logAxiosError({\n        message: `Error uploading code environment file: ${error.message}`,\n        error,\n      }),\n    );\n  }\n}\n\n/**\n * Uploads multiple files to the code execution environment in a single request.","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Files/Code/crud.js#L160-L196","documentation":"Thrown by the single-file upload path (Code/crud.js) when the code server's POST /upload returns a 2xx response but result.message is not the literal 'success'. The server is reachable but rejected the upload at the application layer.","triggerScenarios":"codeapi responds 200 with `{ message: 'invalid_file', ... }` or any non-'success' message — e.g. unsupported MIME type, filename collision policy, quota exceeded, or a malformed multipart form.","commonSituations":"Uploaded a file type the code server rejects; filename contains characters the server forbids; per-user storage quota hit; codeapi version that returns a different success sentinel.","solutions":["Inspect result.message in the response — it carries the code server's own rejection reason.","Confirm the multipart form (FormData) is well-formed and includes the expected fields.","Check the code server's accepted MIME types and per-user quotas.","Verify codeapi version matches the contract that returns `{ message: 'success' }`."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Validate file kind/size before uploading\nconst accepted = ['image/png', 'image/jpeg', 'application/pdf', 'text/plain'];\nif (!accepted.includes(mimeType)) throw new Error(`Unsupported type: ${mimeType}`);","typeGuard":null,"tryCatchPattern":"try {\n  await uploadCodeEnvFile(params);\n} catch (err) {\n  const m = /^Error uploading file: (.+)$/.exec(err.message);\n  if (m) {\n    return res.status(422).json({ message: `Code server rejected upload: ${m[1]}` });\n  }\n  throw err;\n}","preventionTips":["Inspect result.message — it carries the code server's rejection reason.","Validate MIME types and filenames client-side before the upload.","Confirm codeapi version returns the `{ message: 'success' }` contract."],"tags":["code-env","upload","storage","validation"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}