{"record":{"id":"d14c75e3e3a4318b","repo":"Mintplex-Labs/anything-llm","slug":"file-upload-failed","errorCode":null,"errorMessage":"File upload failed.","messagePattern":"File upload failed\\.","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/endpoints/system.js","lineNumber":841,"sourceCode":"        });\n        response.end(Buffer.from(buffer, \"base64\"));\n        return;\n      } catch (error) {\n        console.error(\"Error processing the logo request:\", error);\n        response.status(500).json({ message: \"Internal server error\" });\n      }\n    }\n  );\n\n  app.post(\n    \"/system/upload-pfp\",\n    [validatedRequest, flexUserRoleValid([ROLES.all]), handlePfpUpload],\n    async function (request, response) {\n      try {\n        const user = await userFromSession(request, response);\n        const uploadedFileName = request.randomFileName;\n        if (!uploadedFileName) {\n          return response.status(400).json({ message: \"File upload failed.\" });\n        }\n\n        const userRecord = await User.get({ id: user.id });\n        const oldPfpFilename = userRecord.pfpFilename;\n        if (oldPfpFilename) {\n          const storagePath = path.join(__dirname, \"../storage/assets/pfp\");\n          const oldPfpPath = path.join(\n            storagePath,\n            normalizePath(userRecord.pfpFilename)\n          );\n          if (!isWithin(path.resolve(storagePath), path.resolve(oldPfpPath)))\n            throw new Error(\"Invalid path name\");\n          if (fs.existsSync(oldPfpPath)) fs.unlinkSync(oldPfpPath);\n        }\n\n        const { success, error } = await User.update(user.id, {\n          pfpFilename: uploadedFileName,\n        });","sourceCodeStart":823,"sourceCodeEnd":859,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/20f6d3546c1938bfea1ad304f58a592dddcc5948/server/endpoints/system.js#L823-L859","documentation":"Generic failure response of the POST /system/upload-pfp endpoint: the profile-picture upload pipeline (multer handling via handlePfpUpload middleware or the subsequent save) threw, and no uploaded file name was produced or an exception escaped the try block. It is a catch-all 400/500 sentinel for avatar upload failures.","triggerScenarios":"Thrown at server/endpoints/system.js:827 when the library encounters an invalid state.","commonSituations":"A system file upload failed during processing or storage.","solutions":["Check server logs for the upload/storage error.","Verify the upload directory is writable and the file size/type is allowed, then retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"20f6d3546c1938bfea1ad304f58a592dddcc5948","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}