{"record":{"id":"e5d98ef08b715992","repo":"RocketChat/Rocket.Chat","slug":"invalid-slash-command-parameter-provided-it-must","errorCode":null,"errorMessage":"Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.","messagePattern":"Invalid Slash Command parameter provided, it must be a valid ISlashCommand object\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/app/apps/server/bridges/commands.ts","lineNumber":139,"sourceCode":"\t}\n\n\tprotected async unregisterCommand(command: string, appId: string): Promise<void> {\n\t\tthis.orch.debugLog(`The App ${appId} is unregistering the command: \"${command}\"`);\n\n\t\tif (typeof command !== 'string' || command.trim().length === 0) {\n\t\t\tthrow new Error('Invalid command parameter provided, must be a string.');\n\t\t}\n\n\t\tconst cmd = command.toLowerCase();\n\t\tthis.disabledCommands.delete(cmd);\n\t\tdelete slashCommands.commands[cmd];\n\n\t\tvoid this.orch.getNotifier().commandRemoved(cmd);\n\t}\n\n\tprivate _verifyCommand(command: ISlashCommand): void {\n\t\tif (typeof command !== 'object') {\n\t\t\tthrow new Error('Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.');\n\t\t}\n\n\t\tif (typeof command.command !== 'string') {\n\t\t\tthrow new Error('Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.');\n\t\t}\n\n\t\tif (command.i18nParamsExample && typeof command.i18nParamsExample !== 'string') {\n\t\t\tthrow new Error('Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.');\n\t\t}\n\n\t\tif (command.i18nDescription && typeof command.i18nDescription !== 'string') {\n\t\t\tthrow new Error('Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.');\n\t\t}\n\n\t\tif (typeof command.providesPreview !== 'boolean') {\n\t\t\tthrow new Error('Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.');\n\t\t}\n\t}","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/app/apps/server/bridges/commands.ts#L121-L157","documentation":"`_verifyCommand` (commands.ts:137-140) is the shared guard run at the top of `registerCommand` and `modifyCommand`. Its first check rejects a slash command that is not typeof 'object'. The ISlashCommand comes from the App's `provideSlashCommand()` declaration, so firing here means that declaration returned a non-object command.","triggerScenarios":"App's provideSlashCommand returns undefined, null, a string, or a number instead of an ISlashCommand object; registerCommand/modifyCommand then calls `_verifyCommand` and fails.","commonSituations":"App refactored its command export and forgot to return; a conditional branch that did not return; a spread that lost the object; an `as ISlashCommand` cast hiding the absence.","solutions":["Ensure provideSlashCommand returns a full ISlashCommand object.","Validate the object shape with a type guard before returning it.","Remove `as ISlashCommand` casts so TypeScript enforces the shape."],"exampleFix":"// before\nprovideSlashCommand() { return undefined as any as ISlashCommand }\n// after\nprovideSlashCommand(): ISlashCommand {\n  return { command: 'todo', i18nParamsExample: '', i18nDescription: '', providesPreview: false, executor: async () => {} };\n}","handlingStrategy":"type-guard","validationCode":"const cmd = buildSlashCommand();\nif (!isISlashCommand(cmd)) {\n  throw new Error('provideSlashCommand must return a valid ISlashCommand');\n}\nreturn cmd;","typeGuard":"function isISlashCommand(c: unknown): c is ISlashCommand {\n  return typeof c === 'object' && c !== null\n    && typeof (c as any).command === 'string'\n    && ((c as any).i18nParamsExample == null || typeof (c as any).i18nParamsExample === 'string')\n    && ((c as any).i18nDescription == null || typeof (c as any).i18nDescription === 'string')\n    && typeof (c as any).providesPreview === 'boolean';\n}","tryCatchPattern":null,"preventionTips":["Always return a concrete object from provideSlashCommand; never undefined.","Remove `as ISlashCommand` casts so the compiler enforces the shape.","Run the type guard in tests against every command your app declares."],"tags":["apps-engine","slash-command","validation","typescript"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}