{"record":{"id":"8ed166e6238cd0e8","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-8ed166","errorCode":"error-invalid-user","errorMessage":"Invalid User","messagePattern":"Invalid User","errorType":"error_code","errorClass":"MeteorError","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/bridges/webdav/methods/uploadFileToWebdav.ts","lineNumber":27,"sourceCode":"import { uploadFileToWebdav } from '../lib/uploadFileToWebdav';\n\nconst logger = new Logger('WebDAV_Upload');\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tuploadFileToWebdav(\n\t\t\taccountId: IWebdavAccount['_id'],\n\t\t\tfileData: string | Buffer | ArrayBuffer,\n\t\t\tname: string,\n\t\t): { success: boolean; message?: TranslationKey };\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync uploadFileToWebdav(accountId, fileData, name) {\n\t\tif (!Meteor.userId()) {\n\t\t\tthrow new MeteorError('error-invalid-user', 'Invalid User', {\n\t\t\t\tmethod: 'uploadFileToWebdav',\n\t\t\t});\n\t\t}\n\n\t\tif (!settings.get('Webdav_Integration_Enabled')) {\n\t\t\tthrow new MeteorError('error-not-allowed', 'WebDAV Integration Not Allowed', {\n\t\t\t\tmethod: 'uploadFileToWebdav',\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tawait uploadFileToWebdav(accountId, fileData instanceof ArrayBuffer ? Buffer.from(fileData) : fileData, name);\n\t\t\treturn { success: true };\n\t\t} catch (err: any) {\n\t\t\tif (typeof err === 'object' && err instanceof Error && err.name === 'error-invalid-account') {\n\t\t\t\tthrow new MeteorError(err.name, 'Invalid WebDAV Account', {\n\t\t\t\t\tmethod: 'uploadFileToWebdav',\n\t\t\t\t});","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/bridges/webdav/methods/uploadFileToWebdav.ts#L9-L45","documentation":"First guard in the uploadFileToWebdav Meteor method: Meteor.userId() was falsy on the calling connection, so there is no authenticated user to own the upload. Thrown before the Webdav_Integration_Enabled check or any file handling (including the ArrayBuffer-to-Buffer conversion) runs.","triggerScenarios":"Uploading from a logged-out session; login token expired between opening the dialog and clicking upload; server-side invocation without a user context.","commonSituations":"Session expired in a long-open tab; automated scripts calling the method without a resume token; tests that forget to log in first.","solutions":["Log in and confirm Meteor.userId() is set before initiating the upload","Retry after re-authentication","For server-side flows, call the internal uploadFileToWebdav helper directly with the target account and a Buffer"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  throw new Error('login required before upload');\n}\nawait Meteor.callAsync('uploadFileToWebdav', accountId, fileBuffer, name);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('uploadFileToWebdav', accountId, fileBuffer, name);\n} catch (e: any) {\n  if (e?.error === 'error-invalid-user') {\n    // re-authenticate and let the user retry the upload\n  }\n}","preventionTips":["Disable upload buttons when Meteor.user() is null","For automated flows, ensure a valid resume token exists before starting file transfers"],"tags":["authentication","meteor-methods","webdav","upload"],"backgroundTag":"user-not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}