RocketChat/Rocket.Chat · error · Meteor.Error

error-invalid-user

error-invalid-user

Error message

Invalid User

What it means

First guard in getWebdavFilePreview: Meteor.userId() returned falsy, so the DDP method call arrived on a connection without a valid authenticated user. Nothing WebDAV-specific has run yet; the method refuses to proceed for anonymous callers.

Source

Thrown at apps/meteor/server/bridges/webdav/methods/getWebdavFilePreview.ts:22

import { Meteor } from 'meteor/meteor';
import { createClient } from 'webdav';

import { settings } from '../../../settings';
import { getWebdavCredentials } from '../lib/getWebdavCredentials';

declare module '@rocket.chat/ddp-client' {
	// eslint-disable-next-line @typescript-eslint/naming-convention
	interface ServerMethods {
		getWebdavFilePreview(accountId: IWebdavAccount['_id'], path: string): { success: true; data: ArrayBuffer } | undefined;
	}
}

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

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

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

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

		try {

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Ensure the client is logged in (Meteor.userId() is set) before invoking the method
  2. Re-login or wait for the resume token to be validated, then retry
  3. If called from server code, invoke the underlying logic directly with an explicit userId instead of going through the method
Defensive patterns

Strategy: validation

Validate before calling

const userId = Meteor.userId();
if (!userId) {
  // route to login, or wait for the resume token before calling
  throw new Error('login required');
}
const preview = await Meteor.callAsync('getWebdavFilePreview', accountId, path);

Try / catch

try {
  await Meteor.callAsync('getWebdavFilePreview', accountId, path);
} catch (e: any) {
  if (e?.error === 'error-invalid-user') {
    // session expired: re-authenticate, then re-run the action
  }
}

Prevention

When it happens

Trigger: Invoking the method from a logged-out session, with an expired or invalidated login token, or from server-side code that runs outside a user connection.

Common situations: Login token expired while the tab sat idle and the call races the re-login; code executed in a server-side job or test fixture that calls the method without a user context.

Related errors


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