{"record":{"id":"06e7a4694963b578","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-command-06e7a4","errorCode":"error-invalid-command","errorMessage":"Invalid Command Provided","messagePattern":"Invalid Command Provided","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/messages/executeSlashCommandPreview.ts","lineNumber":33,"sourceCode":"\t\t\t\ttriggerId?: string;\n\t\t\t},\n\t\t\tpreview: SlashCommandPreviewItem,\n\t\t): void;\n\t}\n}\n\nexport const executeSlashCommandPreview = async (\n\tcommand: {\n\t\tcmd: string;\n\t\tparams: string;\n\t\tmsg: RequiredField<Partial<IMessage>, 'rid'>;\n\t\ttriggerId?: string;\n\t},\n\tpreview: SlashCommandPreviewItem,\n\tuserId: string,\n): Promise<void> => {\n\tif (!command?.cmd || !slashCommands.commands[command.cmd]) {\n\t\tthrow new Meteor.Error('error-invalid-command', 'Invalid Command Provided', {\n\t\t\tmethod: 'executeSlashCommandPreview',\n\t\t});\n\t}\n\n\tconst theCmd = slashCommands.commands[command.cmd];\n\tif (!theCmd.providesPreview) {\n\t\tthrow new Meteor.Error('error-invalid-command', 'Command Does Not Provide Previews', {\n\t\t\tmethod: 'executeSlashCommandPreview',\n\t\t});\n\t}\n\n\tif (!preview) {\n\t\tthrow new Meteor.Error('error-invalid-command-preview', 'Invalid Preview Provided', {\n\t\t\tmethod: 'executeSlashCommandPreview',\n\t\t});\n\t}\n\n\treturn slashCommands.executePreview(command.cmd, command.params, command.msg, preview, userId, command.triggerId);","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/messages/executeSlashCommandPreview.ts#L15-L51","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Validate cmd against the command list the server actually exposes (the client-side slashcommand registry) before requesting/executing previews","If the command comes from an App, confirm the App is installed and enabled on this server","For custom commands, register them server-side with slashCommands.add (including the preview options)","Skip the preview call entirely when cmd is empty or unresolved"],"exampleFix":"// before\nMeteor.call('executeSlashCommandPreview', { cmd, params, msg }, preview);\n\n// after\nif (!cmd || !registeredCommands.has(cmd)) {\n  return; // unknown command: no preview\n}\nMeteor.call('executeSlashCommandPreview', { cmd, params, msg }, preview);","handlingStrategy":"validation","validationCode":"const registered = new Set(commands.map((c) => c.command));\nif (!cmd || !registered.has(cmd)) {\n  // unknown command: skip preview entirely\n}\nMeteor.call('executeSlashCommandPreview', { cmd, params, msg }, preview);","typeGuard":"const isRegisteredCommand = (cmd: string, registry: Set<string>): cmd is string => registry.has(cmd);","tryCatchPattern":null,"preventionTips":["Build the command picker from the server-provided registrations, not a hardcoded list","Refresh the command list when Apps are installed, updated, or removed","Only fire preview requests once the typed command resolves to a registration"],"tags":["meteor","slash-command","apps-engine","rocket-chat"],"backgroundTag":"unknown-command","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T10:36:37.832Z"}