RocketChat/Rocket.Chat · error · Error
Invalid command parameter provided, must be a string.
Error message
Invalid command parameter provided, must be a string.
What it means
`AppCommandsBridge.enableCommand(command, appId)` (commands.ts:31-36) re-enables a previously disabled slash command. Its first guard rejects a `command` that is not a non-empty trimmed string. enableCommand is reached via the apps-engine command-modifier accessor; passing anything but a real command name aborts here before any state lookup.
Source
Thrown at apps/meteor/app/apps/server/bridges/commands.ts:35
}
protected async doesCommandExist(command: string, appId: string): Promise<boolean> {
this.orch.debugLog(`The App ${appId} is checking if "${command}" command exists.`);
if (typeof command !== 'string' || command.length === 0) {
return false;
}
const cmd = command.toLowerCase();
return typeof slashCommands.commands[cmd] === 'object' || this.disabledCommands.has(cmd);
}
protected async enableCommand(command: string, appId: string): Promise<void> {
this.orch.debugLog(`The App ${appId} is attempting to enable 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();
if (!this.disabledCommands.has(cmd)) {
throw new Error(`The command is not currently disabled: "${cmd}"`);
}
slashCommands.commands[cmd] = this.disabledCommands.get(cmd) as (typeof slashCommands.commands)[string];
this.disabledCommands.delete(cmd);
void this.orch.getNotifier().commandUpdated(cmd);
}
protected async disableCommand(command: string, appId: string): Promise<void> {
this.orch.debugLog(`The App ${appId} is attempting to disable the command: "${command}"`);
if (typeof command !== 'string' || command.trim().length === 0) {
throw new Error('Invalid command parameter provided, must be a string.');View on GitHub (pinned to f9d3ec372b)
Solutions
- Pass a concrete, non-empty command string.
- Guard with `typeof command === 'string' && command.trim().length > 0` before calling enable.
- Confirm the command was previously disabled (see error 3) in the same process.
Example fix
// before
modifier.enableCommand(name) // name is undefined
// after
if (typeof name === 'string' && name.trim()) {
await modifier.enableCommand(name);
} Defensive patterns
Strategy: validation
Validate before calling
const cmd = asCommandName(rawValue);
if (cmd) {
await modifier.enableCommand(cmd);
} Type guard
const isCommandName = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0;
function asCommandName(v: unknown): string | null {
return isCommandName(v) ? v : null;
} Prevention
- Normalize command names to non-empty strings at the boundary of your app.
- Avoid passing values read from settings/storage without a type check.
- Centralize command lifecycle calls behind a helper that validates the name.
When it happens
Trigger: Calling the command modifier's enable with undefined, a number, an object, or a whitespace-only string — e.g. `getSlashCommandModifier().enableCommand(nameFromConfig)` where nameFromConfig is undefined.
Common situations: App reads the command name from settings/storage that is unset; a programmatic command lookup returned undefined and was passed through; refactor changed the variable type.
Related errors
- Invalid Slash Command parameter provided, it must be a valid
- Invalid Api parameter provided, it must be a valid IApi obje
- 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/2c8337b54b22a69f.
Report an issue: GitHub.