{"record":{"id":"fc79102e5e8e100a","repo":"Mintplex-Labs/anything-llm","slug":"invalid-file-upload-err-message","errorCode":null,"errorMessage":"Invalid file upload. ${err.message}","messagePattern":"Invalid file upload\\. (.+?)","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/utils/files/multer.js","lineNumber":97,"sourceCode":"      normalizePath(file.originalname)\n    )}`;\n    req.randomFileName = randomFileName;\n    cb(null, randomFileName);\n  },\n});\n\n/**\n * Handle Generic file upload as documents from the GUI\n * @param {Request} request\n * @param {Response} response\n * @param {NextFunction} next\n */\nfunction handleFileUpload(request, response, next) {\n  const upload = multer({ storage: fileUploadStorage }).single(\"file\");\n  upload(request, response, function (err) {\n    if (err) {\n      response\n        .status(500)\n        .json({\n          success: false,\n          error: `Invalid file upload. ${err.message}`,\n        })\n        .end();\n      return;\n    }\n    next();\n  });\n}\n\n/**\n * Handle API file upload as documents - this does not manipulate the filename\n * at all for encoding/charset reasons.\n * @param {Request} request\n * @param {Response} response\n * @param {NextFunction} next\n */","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/utils/files/multer.js#L79-L115","documentation":"Multer error handler in handleFileUpload: the multipart upload middleware rejected the request (file too large, unexpected field, etc.), and multer's err.message is wrapped into a 500 response describing the invalid upload.","triggerScenarios":"Multer file upload validation failed. Triggered when an uploaded file fails type/size/extension checks in the generic file upload filter (multer.js:97).","commonSituations":"See trigger scenarios.","solutions":["Read err.message in the response — multer rejected the upload (e.g. file too large or bad multipart body).","Reduce the file size below the upload limit or raise the multer limits in fileUploadStorage.","Ensure the request is multipart/form-data with the file in the 'file' field.","Check the server storage directory exists and is writable."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}