RocketChat/Rocket.Chat · error · Error
The required "roomId" or "roomName" param provided does not
Error message
The required "roomId" or "roomName" param provided does not match any group
What it means
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.
Source
Thrown at apps/meteor/server/lib/unbanUserFromRoom.ts:25
import { RoomMemberActions } from '../../definition/IRoomTypeConfig';
export const unbanUserFromRoom = async (fromId: string, data: { rid: string; username: string }): Promise<boolean> => {
if (!(await hasPermissionAsync(fromId, 'ban-user', data.rid))) {
throw new Error('Not allowed');
}
const room = await Rooms.findOneById(data.rid);
if (!room || !(await roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.BAN, fromId))) {
throw new Error('Not allowed');
}
const fromUser = await Users.findOneById(fromId);
if (!fromUser) {
throw new Error('Invalid user');
}
if (!(await canAccessRoomAsync(room, fromUser))) {
throw new Error('The required "roomId" or "roomName" param provided does not match any group');
}
const bannedUser = await Users.findOneByUsernameIgnoringCase(data.username);
if (!bannedUser) {
throw new Error('User not found');
}
await executeUnbanUserFromRoom(data.rid, bannedUser, fromUser);
return true;
};
View on GitHub (pinned to b2c16d5842)
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'
Example fix
// before
await unbanUserFromRoom(fromId, { rid, username }); // throws misleading 'does not match any group'
// after
const room = await Rooms.findOneById(rid);
const actor = await Users.findOneById(fromId);
if (!room || !actor || !(await canAccessRoomAsync(room, actor))) {
throw new Error('Actor cannot access the target room');
}
await unbanUserFromRoom(fromId, { rid, username }); Defensive patterns
Strategy: validation
Validate before calling
const room = await Rooms.findOneById(rid);
const actor = await Users.findOneById(fromId);
if (!room || !actor || !(await canAccessRoomAsync(room, actor))) {
throw new Error('Actor lacks access to the target room');
}
await unbanUserFromRoom(fromId, { rid, username }); Try / catch
try {
await unbanUserFromRoom(fromId, { rid, username });
} catch (e) {
if (e instanceof Error && e.message.includes('does not match any group')) {
// actually an access denial, not a missing room
throw new Meteor.Error('error-not-allowed', 'Actor cannot access the room');
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/2d7b18f366d94968.
Report an issue: GitHub.