RocketChat/Rocket.Chat · error · Meteor.Error

error-invalid-account

error-invalid-account

Error message

Invalid WebDAV Account

What it means

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.

Source

Thrown at apps/meteor/server/bridges/webdav/methods/getFileFromWebdav.ts:32

	}
}

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

		if (!userId) {
			throw new Meteor.Error('error-invalid-user', 'Invalid User', { method: 'getFileFromWebdav' });
		}
		if (!settings.get('Webdav_Integration_Enabled')) {
			throw new Meteor.Error('error-not-allowed', 'WebDAV Integration Not Allowed', {
				method: 'getFileFromWebdav',
			});
		}

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

		try {
			const cred = getWebdavCredentials(account);
			const client = new WebdavClientAdapter(account.serverURL, cred);
			const fileContent = await client.getFileContents(file.filename);
			const data = new Uint8Array(fileContent);
			return { success: true, data };
		} catch (error) {
			throw new Meteor.Error('unable-to-get-file', 'Unable to get file', {
				method: 'getFileFromWebdav',
			});
		}
	},
});

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Refresh the account list (getWebdavFileList/getWebdavAccounts flow) and use a current accountId owned by the user
  2. If the account was removed, re-add it in Account settings, then retry
  3. Never hardcode account IDs — always resolve them from the live list at call time

Example fix

// before
await call('getFileFromWebdav', staleAccountId, file); // → error-invalid-account

// after
const accounts = await getAccounts(); // live, user-scoped list
const account = accounts.find((a) => a._id === accountId);
if (!account) throw new Error('Account no longer connected');
await call('getFileFromWebdav', account._id, file);
Defensive patterns

Strategy: validation

Validate before calling

const accounts = await getAccounts(); // live, user-scoped WebDAV accounts
if (!accounts.some((a) => a._id === accountId)) {
  throw new Error('Unknown or revoked WebDAV account');
}
await call('getFileFromWebdav', accountId, file);

Try / catch

try {
  await Meteor.callAsync('getFileFromWebdav', accountId, file);
} catch (e) {
  if (e.error === 'error-invalid-account') {
    // refresh the account list; if missing, prompt re-add of the account
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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