{"record":{"id":"7a6b035dcd60dbe1","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-7a6b03","errorCode":"error-invalid-user","errorMessage":"Invalid user","messagePattern":"Invalid user","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/bridges/slack/removeChannelLinks.ts","lineNumber":19,"sourceCode":"import type { ServerMethods } from '@rocket.chat/ddp-client';\nimport { Rooms } from '@rocket.chat/models';\nimport { Meteor } from 'meteor/meteor';\n\nimport { hasPermissionAsync } from '../../lib/authorization/hasPermission';\nimport { settings } from '../../settings';\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tremoveSlackBridgeChannelLinks(): { message: string; params: unknown[] };\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync removeSlackBridgeChannelLinks() {\n\t\tconst user = await Meteor.userAsync();\n\t\tif (!user) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'removeSlackBridgeChannelLinks',\n\t\t\t});\n\t\t}\n\n\t\tif (!(await hasPermissionAsync(user, 'remove-slackbridge-links'))) {\n\t\t\tthrow new Meteor.Error('error-not-authorized', 'Not authorized', {\n\t\t\t\tmethod: 'removeSlackBridgeChannelLinks',\n\t\t\t});\n\t\t}\n\n\t\tif (settings.get('SlackBridge_Enabled') !== true) {\n\t\t\tthrow new Meteor.Error('SlackBridge_disabled');\n\t\t}\n\n\t\tawait Rooms.unsetAllImportIds();\n\n\t\treturn {\n\t\t\tmessage: 'Slackbridge_channel_links_removed_successfully',","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/bridges/slack/removeChannelLinks.ts#L1-L37","documentation":"Thrown by the removeSlackBridgeChannelLinks Meteor method when Meteor.userAsync() returns null - the call was made on a DDP connection with no authenticated user. The user record (not just the id) is needed because it is passed to hasPermissionAsync and used for audit context.","triggerScenarios":"Meteor.call('removeSlackBridgeChannelLinks') from a logged-out client, or after the session expired but before the UI reacted.","commonSituations":"Admin page left open in a background tab whose session lapsed; the operator clicks 'Remove SlackBridge links'. Server-side invocation without user context.","solutions":["Re-authenticate before calling the method; check Meteor.userId() on the client.","Hide/disable the admin control when the session is not valid.","From server code, run within an authenticated user's method context."],"exampleFix":"// before\nMeteor.call('removeSlackBridgeChannelLinks') // logged out\n\n// after\nif (!Meteor.userId()) { await reLogin(); }\nMeteor.call('removeSlackBridgeChannelLinks')","handlingStrategy":"validation","validationCode":"const user = await Meteor.userAsync();\nif (!user) throw new Meteor.Error('error-invalid-user','login required');\nawait Meteor.call('removeSlackBridgeChannelLinks');","typeGuard":"function isAuthenticated() { return typeof Meteor.userId() === 'string'; }","tryCatchPattern":"try { Meteor.call('removeSlackBridgeChannelLinks'); }\ncatch (e) {\n  if (e?.error === 'error-invalid-user') { await reLogin(); Meteor.call('removeSlackBridgeChannelLinks'); return; }\n  throw e;\n}","preventionTips":["Gate destructive admin actions on an active session.","Re-login on session expiry before retrying.","Run server-side within an authenticated user context."],"tags":["meteor","methods","slack","bridge","authentication","users"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}