{"record":{"id":"9ab9a8eba695d27d","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-9ab9a8","errorCode":"error-invalid-user","errorMessage":"Invalid user","messagePattern":"Invalid user","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/messages/executeSlashCommandPreview.ts","lineNumber":58,"sourceCode":"\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},\n});\n","sourceCodeStart":40,"sourceCodeEnd":66,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/messages/executeSlashCommandPreview.ts#L40-L66","documentation":"The Meteor-method wrapper for executeSlashCommandPreview throws 'error-invalid-user' when Meteor.userId() is null — the DDP connection is not authenticated, so the preview execution has no user to run as. Note the thrown details label the method 'getSlashCommandPreview' (a naming quirk of this wrapper); the cause is simply a missing login.","triggerScenarios":"Meteor.call('executeSlashCommandPreview', command, preview) from a session whose token expired or was revoked, or from an anonymous connection.","commonSituations":"Token expiry mid-session while a slash-command preview UI was open; integrations driving slash-command previews over DDP without a login step; test connections without a user.","solutions":["Check Meteor.userId() before invoking; re-authenticate when null and retry","Ensure App-driven preview flows only run inside a logged-in user session","Route integration traffic through authenticated REST endpoints where available"],"exampleFix":"// before\nMeteor.call('executeSlashCommandPreview', command, preview);\n\n// after\nif (!Meteor.userId()) {\n  throw new Error('Login required');\n}\nMeteor.call('executeSlashCommandPreview', command, preview);","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  throw new Error('Login required for slash command previews');\n}\nMeteor.call('executeSlashCommandPreview', command, preview);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('executeSlashCommandPreview', command, preview);\n} catch (e) {\n  if ((e as Meteor.Error).error === 'error-invalid-user') {\n    // re-authenticate, then retry the preview execution once\n  }\n}","preventionTips":["Check Meteor.userId() before any authenticated method call","Match the error code ('error-invalid-user'), not the method label in details","Re-login rather than blindly retrying — the retry will fail identically without a session"],"tags":["meteor","ddp","authentication","slash-command"],"backgroundTag":"user-not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}