{"record":{"id":"b699ac88e0a51085","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-command-preview","errorCode":"error-invalid-command-preview","errorMessage":"Invalid Preview Provided","messagePattern":"Invalid Preview Provided","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/messages/executeSlashCommandPreview.ts","lineNumber":46,"sourceCode":"\t},\n\tpreview: SlashCommandPreviewItem,\n\tuserId: string,\n): Promise<void> => {\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\tif (!preview) {\n\t\tthrow new Meteor.Error('error-invalid-command-preview', 'Invalid Preview Provided', {\n\t\t\tmethod: 'executeSlashCommandPreview',\n\t\t});\n\t}\n\n\treturn slashCommands.executePreview(command.cmd, command.params, command.msg, preview, userId, command.triggerId);\n};\n\nMeteor.methods<ServerMethods>({\n\texecuteSlashCommandPreview(command, preview) {\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: 'getSlashCommandPreview',\n\t\t\t});\n\t\t}\n\n\t\treturn executeSlashCommandPreview(command, preview, userId);\n\t},","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/messages/executeSlashCommandPreview.ts#L28-L64","documentation":"executeSlashCommandPreview requires a preview: SlashCommandPreviewItem as its second argument; a falsy value throws 'error-invalid-command-preview'. The item identifies which preview option the user picked (id/type/value), so without it the server cannot know what to execute.","triggerScenarios":"Meteor.call('executeSlashCommandPreview', command, null) — a handler wiring a button that forgot to forward the selected item, or destructuring that yields undefined because no option was chosen yet.","commonSituations":"Click handlers firing before a selection exists; refactors renaming the preview item fields; races where the preview list was empty and the selected item is undefined.","solutions":["Construct and pass a SlashCommandPreviewItem ({ id, type, value }) sourced from the preview list the user selected","Keep the execute action disabled until a preview option is actually selected","Validate the preview object's shape before invoking the method"],"exampleFix":"// before\nMeteor.call('executeSlashCommandPreview', cmd, selected /* possibly undefined */);\n\n// after\nif (!selected?.id) {\n  return; // nothing chosen yet\n}\nMeteor.call('executeSlashCommandPreview', cmd, selected);","handlingStrategy":"validation","validationCode":"if (!preview || !preview.id || !preview.type) {\n  // nothing selected yet: keep the execute action disabled\n  return;\n}\nMeteor.call('executeSlashCommandPreview', command, preview);","typeGuard":"const isPreviewItem = (p: unknown): p is { id: string; type: string; value: string } =>\n  typeof p === 'object' && p !== null && 'id' in p && 'type' in p && 'value' in p;","tryCatchPattern":null,"preventionTips":["Disable the execute action until a preview option is selected","Type the handler parameter as SlashCommandPreviewItem so undefined cannot reach the call","Guard the object's shape at the boundary (deep links, IPC) where the selection originates"],"tags":["meteor","slash-command","argument-validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}