RocketChat/Rocket.Chat · error · Error
Invalid Slash Command parameter provided, it must be a valid
Error message
Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.
What it means
`_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.
Source
Thrown at apps/meteor/app/apps/server/bridges/commands.ts:139
}
protected async unregisterCommand(command: string, appId: string): Promise<void> {
this.orch.debugLog(`The App ${appId} is unregistering the command: "${command}"`);
if (typeof command !== 'string' || command.trim().length === 0) {
throw new Error('Invalid command parameter provided, must be a string.');
}
const cmd = command.toLowerCase();
this.disabledCommands.delete(cmd);
delete slashCommands.commands[cmd];
void this.orch.getNotifier().commandRemoved(cmd);
}
private _verifyCommand(command: ISlashCommand): void {
if (typeof command !== 'object') {
throw new Error('Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.');
}
if (typeof command.command !== 'string') {
throw new Error('Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.');
}
if (command.i18nParamsExample && typeof command.i18nParamsExample !== 'string') {
throw new Error('Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.');
}
if (command.i18nDescription && typeof command.i18nDescription !== 'string') {
throw new Error('Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.');
}
if (typeof command.providesPreview !== 'boolean') {
throw new Error('Invalid Slash Command parameter provided, it must be a valid ISlashCommand object.');
}
}View on GitHub (pinned to f9d3ec372b)
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.
Example fix
// before
provideSlashCommand() { return undefined as any as ISlashCommand }
// after
provideSlashCommand(): ISlashCommand {
return { command: 'todo', i18nParamsExample: '', i18nDescription: '', providesPreview: false, executor: async () => {} };
} Defensive patterns
Strategy: type-guard
Validate before calling
const cmd = buildSlashCommand();
if (!isISlashCommand(cmd)) {
throw new Error('provideSlashCommand must return a valid ISlashCommand');
}
return cmd; Type guard
function isISlashCommand(c: unknown): c is ISlashCommand {
return typeof c === 'object' && c !== null
&& typeof (c as any).command === 'string'
&& ((c as any).i18nParamsExample == null || typeof (c as any).i18nParamsExample === 'string')
&& ((c as any).i18nDescription == null || typeof (c as any).i18nDescription === 'string')
&& typeof (c as any).providesPreview === 'boolean';
} Prevention
- 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.
When it happens
Trigger: App's provideSlashCommand returns undefined, null, a string, or a number instead of an ISlashCommand object; registerCommand/modifyCommand then calls `_verifyCommand` and fails.
Common situations: 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.
Related errors
- Invalid Api parameter provided, it must be a valid IApi obje
- Invalid command parameter provided, must be a string.
- The command is not currently disabled: "${cmd}"
- Command does not exist in the system currently: "${cmd}"
- Command does not exist in the system currently (or it is dis
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/e5d98ef08b715992.
Report an issue: GitHub.