RocketChat/Rocket.Chat · error · Meteor.Error

error-invalid-user

error-invalid-user

Error message

Invalid user

What it means

`autoTranslate.saveSettings` throws `error-invalid-user` when `Meteor.userId()` is null. Auto-translate settings are stored per user, so a session is mandatory. The method is deprecated since 9.0.0 in favor of `/v1/autotranslate.saveSettings`.

Source

Thrown at apps/meteor/server/meteor-methods/platform/saveSettings.ts:19

import type { ServerMethods } from '@rocket.chat/ddp-client';
import { Meteor } from 'meteor/meteor';

import { saveAutoTranslateSettings } from '../../lib/autotranslate/functions/saveSettings';
import { methodDeprecationLogger } from '../../lib/deprecationWarningLogger';

declare module '@rocket.chat/ddp-client' {
	// eslint-disable-next-line @typescript-eslint/naming-convention
	interface ServerMethods {
		'autoTranslate.saveSettings'(rid: string, field: string, value: string, options: { defaultLanguage: string }): boolean;
	}
}

Meteor.methods<ServerMethods>({
	async 'autoTranslate.saveSettings'(rid, field, value, options) {
		methodDeprecationLogger.method('autoTranslate.saveSettings', '9.0.0', '/v1/autotranslate.saveSettings');
		const userId = Meteor.userId();
		if (!userId) {
			throw new Meteor.Error('error-invalid-user', 'Invalid user', {
				method: 'saveAutoTranslateSettings',
			});
		}

		return saveAutoTranslateSettings(userId, rid, field, value, options);
	},
});

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Require an authenticated session before saving (check `Meteor.userId()`)
  2. Re-login and retry the save when `error-invalid-user` comes back
  3. Migrate to `POST /v1/autotranslate.saveSettings`

Example fix

// before
Meteor.call('autoTranslate.saveSettings', rid, field, value, options);
// after
if (!Meteor.userId()) {
  return promptLogin();
}
Meteor.call('autoTranslate.saveSettings', rid, field, value, options);
Defensive patterns

Strategy: validation

Validate before calling

if (!Meteor.userId()) {
  return handleSessionExpired(); // re-login, then retry the save
}
Meteor.call('autoTranslate.saveSettings', rid, field, value, options);

Try / catch

try {
  await Meteor.callAsync('autoTranslate.saveSettings', rid, field, value, options);
} catch (e) {
  if (e instanceof Meteor.Error && e.error === 'error-invalid-user') {
    // session expired mid-form: re-authenticate and retry the save once
  }
}

Prevention

When it happens

Trigger: Calling `Meteor.call('autoTranslate.saveSettings', rid, field, value, options)` while logged out or with an expired session.

Common situations: Settings dialog left open while the session dropped; saving preferences before login finished on a slow client.

Related errors


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