RocketChat/Rocket.Chat · error · Meteor.Error

error-invalid-account

error-invalid-account

Error message

Invalid WebDAV Account

What it means

Thrown by the getWebdavFileList Meteor method when WebdavAccounts.findOneByIdAndUserId(accountId, userId, {}) returns null, meaning no WebDAV account document matches both the passed accountId and the authenticated user's _id. It is an existence-plus-ownership guard that runs after the invalid-user and Webdav_Integration_Enabled checks, so hitting it means the user and the setting are fine but the account reference is stale, deleted, or foreign.

Source

Thrown at apps/meteor/server/bridges/webdav/methods/getWebdavFileList.ts:33

}

Meteor.methods<ServerMethods>({
	async getWebdavFileList(accountId, path) {
		const userId = Meteor.userId();

		if (!userId) {
			throw new Meteor.Error('error-invalid-user', 'Invalid User', { method: 'getWebdavFileList' });
		}

		if (!settings.get('Webdav_Integration_Enabled')) {
			throw new Meteor.Error('error-not-allowed', 'WebDAV Integration Not Allowed', {
				method: 'getWebdavFileList',
			});
		}

		const account = await WebdavAccounts.findOneByIdAndUserId(accountId, userId, {});
		if (!account) {
			throw new Meteor.Error('error-invalid-account', 'Invalid WebDAV Account', {
				method: 'getWebdavFileList',
			});
		}

		try {
			const cred = getWebdavCredentials(account);
			const client = new WebdavClientAdapter(account.serverURL, cred);
			const data = (await client.getDirectoryContents(path)) as IWebdavNode[];
			return { success: true, data };
		} catch (error) {
			throw new Meteor.Error('could-not-access-webdav', 'Could not access webdav', {
				method: 'getWebdavFileList',
			});
		}
	},
});

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Re-authorize the WebDAV/Nextcloud account so a fresh account document is created, then retry with the new accountId
  2. Before the call, fetch the current user's WebDAV accounts and confirm the accountId you hold still exists
  3. Pass the accountId string exactly as stored in the webdav_accounts collection
  4. If the account was intentionally removed, clear the stale accountId from client state instead of retrying
Defensive patterns

Strategy: validation

Validate before calling

import { WebdavAccounts } from '../../../../../server/models/webdavAccounts';

// server-side: confirm ownership before invoking the method
const userId = Meteor.userId();
if (!userId) throw new Error('login required');
const account = await WebdavAccounts.findOneByIdAndUserId(accountId, userId, {});
if (!account) {
  // drop cached accountId and prompt re-authorization; do not call the method
}

Try / catch

try {
  const res = await Meteor.callAsync('getWebdavFileList', accountId, path);
} catch (e: any) {
  if (e?.error === 'error-invalid-account') {
    // invalidate cached accountId, offer 're-authorize WebDAV' action
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Calling Meteor.call('getWebdavFileList', accountId, path) with an accountId that was deleted, re-created with a new _id after re-authorization, or that belongs to a different user; also passing undefined/null accountId so the lookup matches nothing.

Common situations: User changed their Nextcloud password and re-authorized the integration, so the accountId cached in client state no longer exists; the WebDAV account was removed by an admin while the file picker stayed open; bad prop wiring passes another user's account id.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/96b7f80fd4f7b853. Report an issue: GitHub.