{"record":{"id":"89879e868cb962d8","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-account-89879e","errorCode":"error-invalid-account","errorMessage":"Invalid WebDAV Account","messagePattern":"Invalid WebDAV Account","errorType":"error_code","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/bridges/webdav/methods/getWebdavFilePreview.ts","lineNumber":35,"sourceCode":"Meteor.methods<ServerMethods>({\n\tasync getWebdavFilePreview(accountId, path) {\n\t\tconst userId = Meteor.userId();\n\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid User', {\n\t\t\t\tmethod: 'getWebdavFilePreview',\n\t\t\t});\n\t\t}\n\n\t\tif (!settings.get('Webdav_Integration_Enabled') || !settings.get('Accounts_OAuth_Nextcloud_URL')) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'WebDAV Integration Not Allowed', {\n\t\t\t\tmethod: 'getWebdavFilePreview',\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: 'getWebdavFilePreview',\n\t\t\t});\n\t\t}\n\n\t\ttry {\n\t\t\tconst cred = getWebdavCredentials(account);\n\t\t\tconst client = createClient(account.serverURL, cred);\n\t\t\tconst serverURL = settings.get('Accounts_OAuth_Nextcloud_URL');\n\t\t\tconst res = await client.customRequest(`${serverURL}/index.php/core/preview.png?file=${path}&x=64&y=64`, {\n\t\t\t\tmethod: 'GET',\n\t\t\t\tresponseType: 'arraybuffer',\n\t\t\t});\n\t\t\treturn { success: true, data: res.data as ArrayBuffer };\n\t\t} catch (error) {\n\t\t\t// ignore error\n\t\t}\n\t},\n});","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/bridges/webdav/methods/getWebdavFilePreview.ts#L17-L53","documentation":"The same existence-plus-ownership guard as getWebdavFileList, but inside getWebdavFilePreview: WebdavAccounts.findOneByIdAndUserId(accountId, userId, {}) returned null. It is reached only after the user check and both settings checks passed, so the failure is specifically the accountId/user pair not resolving to a stored WebDAV account.","triggerScenarios":"Requesting a preview with a deleted, re-created, or cross-user accountId; accountId undefined after a client-side state reset; account removed between listing files and clicking one for preview.","commonSituations":"Stale accountId in component state after the user re-authorized Nextcloud; race where an admin removed the account while the user browsed files; URL-parameter-driven UI receiving a bogus accountId.","solutions":["Re-authorize the WebDAV account and use the new accountId","Refresh the account list before rendering the preview action","Validate that the accountId belongs to the logged-in user before calling"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const accounts = await getWebdavAccountsForUser(); // e.g. via the accounts subscription/endpoint\nif (!accounts.some((a) => a._id === accountId)) {\n  // refresh accounts / prompt re-authorization instead of requesting the preview\n}","typeGuard":null,"tryCatchPattern":"try {\n  const { data } = await Meteor.callAsync('getWebdavFilePreview', accountId, path);\n} catch (e: any) {\n  if (e?.error === 'error-invalid-account') {\n    // re-sync account list, then let the user retry from a valid account\n  }\n}","preventionTips":["Derive the accountId for previews from the same live account object that produced the file listing","Re-fetch accounts when the file picker mounts, not once per session"],"tags":["webdav","meteor-methods","account-ownership","preview"],"backgroundTag":"resource-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}