{"record":{"id":"371290ad00741b17","repo":"RocketChat/Rocket.Chat","slug":"the-required-roomid-or-roomname-param-provided","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":null,"httpStatus":400,"severity":"error","filePath":"apps/meteor/server/lib/banUserFromRoom.ts","lineNumber":28,"sourceCode":"\nexport const banUserFromRoomMethod = 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\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\tconst subscription = await Subscriptions.findOneByRoomIdAndUserId(data.rid, bannedUser._id, {\n\t\tprojection: { _id: 1, status: 1 },\n\t});\n\tif (!subscription) {\n\t\tthrow new Error('User is not in this room');\n\t}\n\n\t// Cannot ban a user who is already banned\n\tif (isBannedSubscription(subscription)) {\n\t\tthrow new Error('User is already banned from this room');\n\t}","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/banUserFromRoom.ts#L10-L46","documentation":"canAccessRoomAsync(room, fromUser) failed in banUserFromRoomMethod: the banner, despite holding ban-user permission, cannot access that specific room - typically a private channel or team room they are not a member of. The message text is copied from the groups REST layer and is misleading: the room exists, the caller just cannot act in it.","triggerScenarios":"A global moderator with ban-user trying to ban in a private room they never joined; a team-internal private channel; a banner who left the room but retained the permission.","commonSituations":"Compliance/moderation roles designed with global permissions but no room membership; permission models that assume room-scoped moderation.","solutions":["Add the moderator to the room, or design permission grants so banners are always members","Pre-check the caller can access the room before exposing the ban action","For cross-room moderation, use an admin-scoped integration instead"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const subs = await GET '/api/v1/subscriptions.get';\nif (!subs.update.some((s) => s.rid === roomId)) {\n  // banner cannot access a room they are not in (e.g. private channel) - join first\n}","typeGuard":null,"tryCatchPattern":"try {\n  await POST '/api/v1/rooms.banUser' { roomId, username };\n} catch (e) {\n  if (String(e.message).includes('does not match any group')) {\n    // misleading text: room exists but caller cannot access it - add banner to the room\n  } else {\n    throw e;\n  }\n}","preventionTips":["Design moderation roles so banners are members of the rooms they moderate","Pre-check membership for private rooms before enabling ban actions","Do not read this message as a room-lookup failure - it is an access denial"],"tags":["rocket-chat","rooms","moderation","access-control","private-channels"],"backgroundTag":"room-access-denied","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}