{"record":{"id":"2d7b18f366d94968","repo":"RocketChat/Rocket.Chat","slug":"the-required-roomid-or-roomname-param-provided-2d7b18","errorCode":null,"errorMessage":"The required \"roomId\" or \"roomName\" param provided does not match any group","messagePattern":"The required \"roomId\" or \"roomName\" param provided does not match any group","errorType":"exception","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/server/lib/unbanUserFromRoom.ts","lineNumber":25,"sourceCode":"import { RoomMemberActions } from '../../definition/IRoomTypeConfig';\n\nexport const unbanUserFromRoom = async (fromId: string, data: { rid: string; username: string }): Promise<boolean> => {\n\tif (!(await hasPermissionAsync(fromId, 'ban-user', data.rid))) {\n\t\tthrow new Error('Not allowed');\n\t}\n\n\tconst room = await Rooms.findOneById(data.rid);\n\tif (!room || !(await roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.BAN, fromId))) {\n\t\tthrow new Error('Not allowed');\n\t}\n\n\tconst fromUser = await Users.findOneById(fromId);\n\tif (!fromUser) {\n\t\tthrow new Error('Invalid user');\n\t}\n\n\tif (!(await canAccessRoomAsync(room, fromUser))) {\n\t\tthrow new Error('The required \"roomId\" or \"roomName\" param provided does not match any group');\n\t}\n\n\tconst bannedUser = await Users.findOneByUsernameIgnoringCase(data.username);\n\tif (!bannedUser) {\n\t\tthrow new Error('User not found');\n\t}\n\n\tawait executeUnbanUserFromRoom(data.rid, bannedUser, fromUser);\n\n\treturn true;\n};\n","sourceCodeStart":7,"sourceCodeEnd":37,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/unbanUserFromRoom.ts#L7-L37","documentation":"Thrown by unbanUserFromRoom when the room was found but the acting user (fromId) fails canAccessRoomAsync(room, fromUser). Despite the wording about 'roomId or roomName', this is not a lookup failure: the user invoking the unban cannot access the room (not a member of the private channel, no subscription, or lacking the required permission). The message is borrowed from REST param validation and is misleading.","triggerScenarios":"Running the /unban slash command (apps/meteor/server/slashcommands/ban/unban.ts) or the rooms unban REST path (apps/meteor/server/api/v1/rooms.ts:1687) where the acting user has no access to the room: e.g. a moderator who was removed from a private channel, or server-side automation using a token whose user never joined the room.","commonSituations":"Admin bots calling unban with a bot account that has no subscription in the target room; users unbanning someone in a private channel they left; DMs or team rooms where the actor's subscription was deleted.","solutions":["Verify the acting user has a subscription in the room (e.g. Subscriptions.findOneByRoomIdAndUserId or GET /api/v1/rooms.info as that user) and re-join if not","Pre-check access with canAccessRoomAsync(room, fromUser) before calling unbanUserFromRoom so the denial is surfaced as a permission problem, not a generic error","If automating moderation, run with an account that holds the necessary room membership/role (owner, moderator, or admin with access)","Do not rely on the message text: treat this error as 403-style access denial, not 'room does not exist'"],"exampleFix":"// before\nawait unbanUserFromRoom(fromId, { rid, username }); // throws misleading 'does not match any group'\n\n// after\nconst room = await Rooms.findOneById(rid);\nconst actor = await Users.findOneById(fromId);\nif (!room || !actor || !(await canAccessRoomAsync(room, actor))) {\n  throw new Error('Actor cannot access the target room');\n}\nawait unbanUserFromRoom(fromId, { rid, username });","handlingStrategy":"validation","validationCode":"const room = await Rooms.findOneById(rid);\nconst actor = await Users.findOneById(fromId);\nif (!room || !actor || !(await canAccessRoomAsync(room, actor))) {\n  throw new Error('Actor lacks access to the target room');\n}\nawait unbanUserFromRoom(fromId, { rid, username });","typeGuard":null,"tryCatchPattern":"try {\n  await unbanUserFromRoom(fromId, { rid, username });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('does not match any group')) {\n    // actually an access denial, not a missing room\n    throw new Meteor.Error('error-not-allowed', 'Actor cannot access the room');\n  }\n  throw e;\n}","preventionTips":["Maintain room membership for moderation bots that need to unban","Pre-check canAccessRoomAsync before any moderation call","Never branch on this message text to conclude the room is gone"],"tags":["rooms","bans","permissions","authorization","meteor-methods"],"backgroundTag":"room-access-denied","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}