{"record":{"id":"78491f68ea3c3dbd","repo":"RocketChat/Rocket.Chat","slug":"mention-bot-failed-to-retrieve-room-information","errorCode":null,"errorMessage":"Mention bot - Failed to retrieve room information","messagePattern":"Mention bot - Failed to retrieve room information","errorType":"exception","errorClass":"Error","httpStatus":500,"severity":"error","filePath":"apps/meteor/server/modules/core-apps/mention.module.ts","lineNumber":79,"sourceCode":"\t\tif (actionId === 'add-users') {\n\t\t\tvoid addUsersToRoomMethod(user._id, { rid: room, users: usernames as string[] }, user);\n\t\t\tvoid api.broadcast('notify.ephemeralMessage', user._id, room, {\n\t\t\t\tmsg: i18n.t('You_mentioned___mentions__but_theyre_not_in_this_room', {\n\t\t\t\t\tmentions: joinedUsernames,\n\t\t\t\t\tlng: user.language,\n\t\t\t\t}),\n\t\t\t\ttmid: message.tmid,\n\t\t\t\t_id: payload.message,\n\t\t\t\tmentions,\n\t\t\t});\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (actionId === 'share-message') {\n\t\t\tconst sub = await Subscriptions.findOneByRoomIdAndUserId(room, user._id, { projection: { t: 1, rid: 1, name: 1 } });\n\t\t\t// this should exist since the event is fired from withing the room (e.g the user sent a message)\n\t\t\tif (!sub) {\n\t\t\t\tthrow new Error('Mention bot - Failed to retrieve room information');\n\t\t\t}\n\n\t\t\tconst roomPath = roomCoordinator.getRouteLink(sub.t, { rid: sub.rid, name: sub.name });\n\t\t\tif (!roomPath) {\n\t\t\t\tthrow new Error('Mention bot - Failed to retrieve path to room');\n\t\t\t}\n\n\t\t\tconst messageText = i18n.t('Youre_not_a_part_of__channel__and_I_mentioned_you_there', {\n\t\t\t\tchannel: `#${sub.name}`,\n\t\t\t\tlng: user.language,\n\t\t\t});\n\n\t\t\tconst link = new URL(Meteor.absoluteUrl(roomPath));\n\t\t\tlink.searchParams.set('msg', message._id);\n\t\t\tconst text = `[ ](${link.toString()})\\n${messageText}`;\n\n\t\t\t// forwards message to all DMs\n\t\t\tawait processWebhookMessage(","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/modules/core-apps/mention.module.ts#L61-L97","documentation":"Thrown by Rocket.Chat's mention bot core app (MentionModule, appId 'mention-core'). When a user clicks 'share-message' on the banner shown after mentioning users who cannot see the room, the module loads the clicker's own subscription via Subscriptions.findOneByRoomIdAndUserId(room, user._id) to build a deep link to the message. A null result means the server no longer considers this user a member of the room the banner was rendered in, so the share is aborted.","triggerScenarios":"A UiKit blockAction dispatched with appId 'mention-core' and actionId 'share-message' where Subscriptions.findOneByRoomIdAndUserId(payload.room, user._id) returns null: the user left or was removed from the channel after the banner rendered, or the payload carries a stale/incorrect room id.","commonSituations":"User leaves (or is kicked from) a channel while the 'you mentioned users not in this room' banner is still on screen, then clicks Share; hand-built UiKit payloads in tests pointing at a room the user never joined.","solutions":["Re-check that the user is still a member of the room before showing or handling 'share-message', and hide the action if not","If membership was lost, have the user rejoin the room, re-send the mention, and use the fresh banner","Catch the error where UiKit actions are executed and reply with an ephemeral 'you are no longer in this room' notice instead of surfacing a server error","If it reproduces for an active member, inspect the subscriptions collection for a missing/corrupt document for that rid+uid pair"],"exampleFix":"// before\nawait mentionModule.blockAction(payload); // may throw 'Mention bot - Failed to retrieve room information'\n\n// after\nconst sub = await Subscriptions.findOneByRoomIdAndUserId(payload.room!, payload.user!._id, { projection: { t: 1 } });\nif (!sub) {\n  void api.broadcast('notify.ephemeralMessage', payload.user!._id, payload.room!, { msg: 'You are no longer in this room' });\n  return;\n}\nawait mentionModule.blockAction(payload);","handlingStrategy":"try-catch","validationCode":"const canShareMessage = async (userId: string, rid: string): Promise<boolean> =>\n  Boolean(await Subscriptions.findOneByRoomIdAndUserId(rid, userId, { projection: { _id: 1 } }));","typeGuard":null,"tryCatchPattern":"try {\n  await mentionModule.blockAction(payload);\n} catch (error) {\n  if (error instanceof Error && error.message === 'Mention bot - Failed to retrieve room information') {\n    // user lost membership mid-flow; show an ephemeral notice instead of failing\n    return notifyMembershipLost(payload.user!._id, payload.room!);\n  }\n  throw error;\n}","preventionTips":["Re-verify room membership at click time, not only at banner-render time","In custom clients, drop UiKit banners as soon as the local subscription for that room is removed","Never cache the room id in the banner payload beyond the session that rendered it"],"tags":["uikit","mention-bot","subscriptions","rocket-chat-server"],"backgroundTag":"missing-room-membership","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}