RocketChat/Rocket.Chat · error · Meteor.Error

error-invalid-user

error-invalid-user

Error message

Invalid user

What it means

The Meteor-method wrapper for executeSlashCommandPreview throws 'error-invalid-user' when Meteor.userId() is null — the DDP connection is not authenticated, so the preview execution has no user to run as. Note the thrown details label the method 'getSlashCommandPreview' (a naming quirk of this wrapper); the cause is simply a missing login.

Source

Thrown at apps/meteor/server/meteor-methods/messages/executeSlashCommandPreview.ts:58

		throw new Meteor.Error('error-invalid-command', 'Command Does Not Provide Previews', {
			method: 'executeSlashCommandPreview',
		});
	}

	if (!preview) {
		throw new Meteor.Error('error-invalid-command-preview', 'Invalid Preview Provided', {
			method: 'executeSlashCommandPreview',
		});
	}

	return slashCommands.executePreview(command.cmd, command.params, command.msg, preview, userId, command.triggerId);
};

Meteor.methods<ServerMethods>({
	executeSlashCommandPreview(command, preview) {
		const userId = Meteor.userId();
		if (!userId) {
			throw new Meteor.Error('error-invalid-user', 'Invalid user', {
				method: 'getSlashCommandPreview',
			});
		}

		return executeSlashCommandPreview(command, preview, userId);
	},
});

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Check Meteor.userId() before invoking; re-authenticate when null and retry
  2. Ensure App-driven preview flows only run inside a logged-in user session
  3. Route integration traffic through authenticated REST endpoints where available

Example fix

// before
Meteor.call('executeSlashCommandPreview', command, preview);

// after
if (!Meteor.userId()) {
  throw new Error('Login required');
}
Meteor.call('executeSlashCommandPreview', command, preview);
Defensive patterns

Strategy: validation

Validate before calling

if (!Meteor.userId()) {
  throw new Error('Login required for slash command previews');
}
Meteor.call('executeSlashCommandPreview', command, preview);

Try / catch

try {
  await Meteor.callAsync('executeSlashCommandPreview', command, preview);
} catch (e) {
  if ((e as Meteor.Error).error === 'error-invalid-user') {
    // re-authenticate, then retry the preview execution once
  }
}

Prevention

When it happens

Trigger: Meteor.call('executeSlashCommandPreview', command, preview) from a session whose token expired or was revoked, or from an anonymous connection.

Common situations: Token expiry mid-session while a slash-command preview UI was open; integrations driving slash-command previews over DDP without a login step; test connections without a user.

Related errors


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