RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-command
error-invalid-command
Error message
Invalid Command Provided
What it means
getSlashCommandPreviews throws 'error-invalid-command' ('Invalid Command Provided') when command.cmd is falsy or absent from the server's slashCommands.commands registry — the same registry check executeSlashCommandPreview performs (the thrown detail even names method 'executeSlashCommandPreview'). Only commands registered server-side, by core or by installed and enabled Apps, can produce previews.
Source
Thrown at apps/meteor/server/meteor-methods/messages/getSlashCommandPreviews.ts:25
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
getSlashCommandPreviews(command: {
cmd: string;
params: string;
msg: RequiredField<Partial<IMessage>, 'rid'>;
}): SlashCommandPreviews | undefined;
}
}
export const getSlashCommandPreviews = async (command: {
cmd: string;
params: string;
msg: RequiredField<Partial<IMessage>, 'rid'>;
userId: string;
}): Promise<SlashCommandPreviews | undefined> => {
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',
});
}
return slashCommands.getPreviews(command.cmd, command.params, command.msg, command.userId);
};
Meteor.methods<ServerMethods>({
async getSlashCommandPreviews(command) {
const userId = Meteor.userId();
if (!userId) {View on GitHub (pinned to b2c16d5842)
Solutions
- Validate cmd against the server-provided command list before requesting previews
- Ensure the App providing the command is installed and enabled on this workspace
- Register custom commands server-side via slashCommands.add (with preview options) if they are yours
Example fix
// before
Meteor.call('getSlashCommandPreviews', { cmd, params, msg, userId });
// after
if (!cmd || !registeredCommands.has(cmd)) {
return; // no previews for unknown commands
}
Meteor.call('getSlashCommandPreviews', { cmd, params, msg, userId }); Defensive patterns
Strategy: type-guard
Type guard
const isRegisteredCommand =
(cmd: string, commands: Set<string>): cmd is string =>
commands.has(cmd);
// usage:
const registered = new Set(commands.map((c) => c.command));
if (isRegisteredCommand(cmd, registered)) {
Meteor.call('getSlashCommandPreviews', { cmd, params, msg, userId });
} Prevention
- Populate the preview-capable command set from server registrations, not a static list
- Refresh registrations on App install/uninstall and reconnect
- Skip preview requests for empty or unresolved command tokens
When it happens
Trigger: Meteor.call('getSlashCommandPreviews', { cmd, params, msg, userId }) with a typo'd or unregistered command, an App command whose app is disabled, or an empty cmd.
Common situations: Clients building preview UIs from stale or hardcoded command lists; Apps uninstalled after clients cached their registrations; command drift between server versions.
Related errors
- error-invalid-command
- error-user-already-in-room
- error-invalid-user
- error-invalid-user
- error-app-prevented
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/d8eb0fb59ad5ad1f.
Report an issue: GitHub.