RocketChat/Rocket.Chat · error · Meteor.Error

error-invalid-command

error-invalid-command

Error message

Invalid Command Provided

What it means

executeSlashCommandPreview throws 'error-invalid-command' ('Invalid Command Provided') when command.cmd is falsy or absent from the server's slashCommands.commands registry. That registry only contains commands registered server-side (core slash commands or commands provided by installed and enabled Apps), so any unknown name fails here before preview logic runs.

Source

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

				triggerId?: string;
			},
			preview: SlashCommandPreviewItem,
		): void;
	}
}

export const executeSlashCommandPreview = async (
	command: {
		cmd: string;
		params: string;
		msg: RequiredField<Partial<IMessage>, 'rid'>;
		triggerId?: string;
	},
	preview: SlashCommandPreviewItem,
	userId: string,
): Promise<void> => {
	if (!command?.cmd || !slashCommands.commands[command.cmd]) {
		throw new Meteor.Error('error-invalid-command', 'Invalid Command Provided', {
			method: 'executeSlashCommandPreview',
		});
	}

	const theCmd = slashCommands.commands[command.cmd];
	if (!theCmd.providesPreview) {
		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);

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Validate cmd against the command list the server actually exposes (the client-side slashcommand registry) before requesting/executing previews
  2. If the command comes from an App, confirm the App is installed and enabled on this server
  3. For custom commands, register them server-side with slashCommands.add (including the preview options)
  4. Skip the preview call entirely when cmd is empty or unresolved

Example fix

// before
Meteor.call('executeSlashCommandPreview', { cmd, params, msg }, preview);

// after
if (!cmd || !registeredCommands.has(cmd)) {
  return; // unknown command: no preview
}
Meteor.call('executeSlashCommandPreview', { cmd, params, msg }, preview);
Defensive patterns

Strategy: validation

Validate before calling

const registered = new Set(commands.map((c) => c.command));
if (!cmd || !registered.has(cmd)) {
  // unknown command: skip preview entirely
}
Meteor.call('executeSlashCommandPreview', { cmd, params, msg }, preview);

Type guard

const isRegisteredCommand = (cmd: string, registry: Set<string>): cmd is string => registry.has(cmd);

Prevention

When it happens

Trigger: Calling executeSlashCommandPreview with a command name the server never registered: a typo, a client-only command, or an App command whose app was disabled or uninstalled after the client cached its list.

Common situations: Custom clients building command UIs from hardcoded command lists; Apps toggled off server-side while connected clients keep offering their commands; version drift where a command exists on one server but not another.

Related errors


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