{"record":{"id":"61968e6c844fc371","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-command","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/lib/utils/slashCommand.ts","lineNumber":153,"sourceCode":"declare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tslashCommand(params: { cmd: string; params: string; msg: IMessage; triggerId: string }): unknown;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync slashCommand(command) {\n\t\tmethodDeprecationLogger.method('slashCommand', '9.0.0', '/v1/commands.run');\n\t\tconst userId = Meteor.userId();\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'slashCommand',\n\t\t\t});\n\t\t}\n\n\t\tif (!command?.cmd || !slashCommands.commands[command.cmd]) {\n\t\t\tthrow new Meteor.Error('error-invalid-command', 'Invalid Command Provided', {\n\t\t\t\tmethod: 'executeSlashCommandPreview',\n\t\t\t});\n\t\t}\n\n\t\treturn slashCommands.run({\n\t\t\tcommand: command.cmd,\n\t\t\tparams: command.params,\n\t\t\tmessage: command.msg,\n\t\t\ttriggerId: command.triggerId,\n\t\t\tuserId,\n\t\t});\n\t},\n});\n","sourceCodeStart":135,"sourceCodeEnd":167,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/utils/slashCommand.ts#L135-L167","documentation":"The 'slashCommand' method throws error-invalid-command when command.cmd is falsy or the name is absent from the global slashCommands.commands registry (no command registered under that name with a callback). Commands register server-side via slashCommands.add (core) or through the Apps Engine (apps). Note the error details carry a stale method name ('executeSlashCommandPreview') — a copy-paste artifact in the source.","triggerScenarios":"Meteor.call('slashCommand', { cmd: '/unknown', ... }) for a never-registered command; invoking an app-provided slash command while the app is disabled or uninstalled; mismatched cmd casing or an unexpected leading '/' character.","commonSituations":"Typos in command names; app commands unavailable after the app was disabled; environments missing an app/enterprise module that provides the command; version upgrades that renamed or removed commands.","solutions":["Verify the exact registered command name (inspect its slashCommands.add registration, or GET /api/v1/commands.list for commands available to the user).","Re-enable or reinstall the app/module that provides the command.","For custom commands, make sure slashCommands.add ran on the server before invocation.","Send cmd consistently without the leading '/' (the UI strips it before dispatch)."],"exampleFix":"// before: typo'd / unregistered name\nMeteor.call('slashCommand', { cmd: 'gimmeA', params: 'cat', msg });\n\n// after: exact registered name, no leading slash\nMeteor.call('slashCommand', { cmd: 'gimme', params: 'cat', msg });","handlingStrategy":"validation","validationCode":"// Server-side: confirm the command is registered before dispatching\nconst isRegisteredCommand = (cmd: string): boolean =>\n  Boolean(cmd && slashCommands.commands[cmd] && typeof slashCommands.commands[cmd].callback === 'function');","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('slashCommand', { cmd, params, msg });\n} catch (err: any) {\n  if (err?.error === 'error-invalid-command') {\n    showWarning(`Command \"${cmd}\" is not available on this server`);\n    await refreshAvailableCommands(); // e.g. GET /api/v1/commands.list\n    return;\n  }\n  throw err;\n}","preventionTips":["Derive command names from the registration source, not string literals scattered in the client.","Re-check availability after enabling/disabling apps — app commands unregister with the app.","Strip the leading '/' consistently before sending cmd."],"tags":["slash-commands","unknown-command","meteor-methods","validation"],"backgroundTag":"unknown-command","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}