{"record":{"id":"d8eb0fb59ad5ad1f","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-command-d8eb0f","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/getSlashCommandPreviews.ts","lineNumber":25,"sourceCode":"declare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tgetSlashCommandPreviews(command: {\n\t\t\tcmd: string;\n\t\t\tparams: string;\n\t\t\tmsg: RequiredField<Partial<IMessage>, 'rid'>;\n\t\t}): SlashCommandPreviews | undefined;\n\t}\n}\n\nexport const getSlashCommandPreviews = async (command: {\n\tcmd: string;\n\tparams: string;\n\tmsg: RequiredField<Partial<IMessage>, 'rid'>;\n\tuserId: string;\n}): Promise<SlashCommandPreviews | undefined> => {\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\treturn slashCommands.getPreviews(command.cmd, command.params, command.msg, command.userId);\n};\n\nMeteor.methods<ServerMethods>({\n\tasync getSlashCommandPreviews(command) {\n\t\tconst userId = Meteor.userId();\n\t\tif (!userId) {","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/messages/getSlashCommandPreviews.ts#L7-L43","documentation":"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.","triggerScenarios":"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.","commonSituations":"Clients building preview UIs from stale or hardcoded command lists; Apps uninstalled after clients cached their registrations; command drift between server versions.","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"],"exampleFix":"// before\nMeteor.call('getSlashCommandPreviews', { cmd, params, msg, userId });\n\n// after\nif (!cmd || !registeredCommands.has(cmd)) {\n  return; // no previews for unknown commands\n}\nMeteor.call('getSlashCommandPreviews', { cmd, params, msg, userId });","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"const isRegisteredCommand =\n  (cmd: string, commands: Set<string>): cmd is string =>\n    commands.has(cmd);\n\n// usage:\nconst registered = new Set(commands.map((c) => c.command));\nif (isRegisteredCommand(cmd, registered)) {\n  Meteor.call('getSlashCommandPreviews', { cmd, params, msg, userId });\n}","tryCatchPattern":null,"preventionTips":["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"],"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-21T11:28:35.574Z"}