{"record":{"id":"a56db47a2e6e832f","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-account","errorCode":"error-invalid-account","errorMessage":"Invalid WebDAV Account","messagePattern":"Invalid WebDAV Account","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/bridges/webdav/methods/getFileFromWebdav.ts","lineNumber":32,"sourceCode":"\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);\n\t\t\tconst data = new Uint8Array(fileContent);\n\t\t\treturn { success: true, data };\n\t\t} catch (error) {\n\t\t\tthrow new Meteor.Error('unable-to-get-file', 'Unable to get file', {\n\t\t\t\tmethod: 'getFileFromWebdav',\n\t\t\t});\n\t\t}\n\t},\n});\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/bridges/webdav/methods/getFileFromWebdav.ts#L14-L50","documentation":"getFileFromWebdav looks up the WebDAV account with findOneByIdAndUserId(accountId, userId) — both the account ID and ownership must match. A null result throws error-invalid-account ('Invalid WebDAV Account'), meaning the accountId is unknown, was deleted, or belongs to a different user. This runs after the auth and settings checks, so it specifically indicates an account-reference problem.","triggerScenarios":"Passing an accountId that no longer exists (account removed in settings) or that belongs to another user; using an ID from a stale client-side cache after the account list changed; malformed IDs that match nothing.","commonSituations":"File-picker state kept across page reloads while the user deleted and re-added the account; multi-account setups where the wrong ID was passed; another session revoked the account between listing and downloading.","solutions":["Refresh the account list (getWebdavFileList/getWebdavAccounts flow) and use a current accountId owned by the user","If the account was removed, re-add it in Account settings, then retry","Never hardcode account IDs — always resolve them from the live list at call time"],"exampleFix":"// before\nawait call('getFileFromWebdav', staleAccountId, file); // → error-invalid-account\n\n// after\nconst accounts = await getAccounts(); // live, user-scoped list\nconst account = accounts.find((a) => a._id === accountId);\nif (!account) throw new Error('Account no longer connected');\nawait call('getFileFromWebdav', account._id, file);","handlingStrategy":"validation","validationCode":"const accounts = await getAccounts(); // live, user-scoped WebDAV accounts\nif (!accounts.some((a) => a._id === accountId)) {\n  throw new Error('Unknown or revoked WebDAV account');\n}\nawait call('getFileFromWebdav', accountId, file);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('getFileFromWebdav', accountId, file);\n} catch (e) {\n  if (e.error === 'error-invalid-account') {\n    // refresh the account list; if missing, prompt re-add of the account\n  }\n}","preventionTips":["Always resolve accountId from the live account list at call time","Invalidate cached pickers when the account list changes","Scope account IDs per user — they are ownership-checked server-side"],"tags":["webdav","meteor","account","validation"],"backgroundTag":"account-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}