{"record":{"id":"26230a294ed75a16","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-26230a","errorCode":"error-invalid-user","errorMessage":"Invalid User","messagePattern":"Invalid User","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/bridges/webdav/methods/getFileFromWebdav.ts","lineNumber":22,"sourceCode":"import { Meteor } from 'meteor/meteor';\n\nimport { settings } from '../../../settings';\nimport { getWebdavCredentials } from '../lib/getWebdavCredentials';\nimport { WebdavClientAdapter } from '../lib/webdavClientAdapter';\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tgetFileFromWebdav(accountId: IWebdavAccount['_id'], file: IWebdavNode): Promise<{ success: boolean; data: Uint8Array<ArrayBuffer> }>;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync getFileFromWebdav(accountId, file) {\n\t\tconst userId = Meteor.userId();\n\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid User', { method: 'getFileFromWebdav' });\n\t\t}\n\t\tif (!settings.get('Webdav_Integration_Enabled')) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'WebDAV Integration Not Allowed', {\n\t\t\t\tmethod: 'getFileFromWebdav',\n\t\t\t});\n\t\t}\n\n\t\tconst account = await WebdavAccounts.findOneByIdAndUserId(accountId, userId, {});\n\t\tif (!account) {\n\t\t\tthrow new Meteor.Error('error-invalid-account', 'Invalid WebDAV Account', {\n\t\t\t\tmethod: 'getFileFromWebdav',\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst cred = getWebdavCredentials(account);\n\t\t\tconst client = new WebdavClientAdapter(account.serverURL, cred);\n\t\t\tconst fileContent = await client.getFileContents(file.filename);","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/bridges/webdav/methods/getFileFromWebdav.ts#L4-L40","documentation":"getFileFromWebdav is the DDP method that downloads a file's bytes from a user's connected WebDAV account. It throws error-invalid-user when Meteor.userId() is falsy — the calling connection has no authenticated user. The check precedes the integration-setting, account, and download steps, so unauthenticated calls never reach the WebDAV server.","triggerScenarios":"Calling Meteor.call('getFileFromWebdav', accountId, file) from a connection without a valid login, e.g. an expired session in a file-picker UI or an unauthenticated script.","commonSituations":"File-picker dialogs left open past token expiry; automation fetching WebDAV files without DDP authentication; server-side code calling the method without binding a user.","solutions":["Authenticate the DDP connection before requesting files","Re-login on session expiry and retry the download once","In UIs, gate file fetches on a live session check"],"exampleFix":"// before\nMeteor.call('getFileFromWebdav', accountId, file); // → error-invalid-user\n\n// after\nif (!Meteor.userId()) await relogin();\nMeteor.call('getFileFromWebdav', accountId, file, (err) => { /* handle */ });","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  await relogin();\n}\nawait Meteor.callAsync('getFileFromWebdav', accountId, file);","typeGuard":null,"tryCatchPattern":"Meteor.call('getFileFromWebdav', accountId, file, (err) => {\n  if (err && err.error === 'error-invalid-user') {\n    // session expired in the file picker: re-login, then re-request\n  }\n});","preventionTips":["File pickers should verify session liveness on open","Re-authenticate before retrying downloads after idle periods","Avoid caching download triggers across sessions"],"tags":["meteor","webdav","authentication","file-download"],"backgroundTag":"meteor-error-invalid-user","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}