RocketChat/Rocket.Chat · 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

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.

Source

Thrown at apps/meteor/server/lib/banUserFromRoom.ts:28

export const banUserFromRoomMethod = 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');
	}

	const subscription = await Subscriptions.findOneByRoomIdAndUserId(data.rid, bannedUser._id, {
		projection: { _id: 1, status: 1 },
	});
	if (!subscription) {
		throw new Error('User is not in this room');
	}

	// Cannot ban a user who is already banned
	if (isBannedSubscription(subscription)) {
		throw new Error('User is already banned from this room');
	}

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Add the moderator to the room, or design permission grants so banners are always members
  2. Pre-check the caller can access the room before exposing the ban action
  3. For cross-room moderation, use an admin-scoped integration instead
Defensive patterns

Strategy: validation

Validate before calling

const subs = await GET '/api/v1/subscriptions.get';
if (!subs.update.some((s) => s.rid === roomId)) {
  // banner cannot access a room they are not in (e.g. private channel) - join first
}

Try / catch

try {
  await POST '/api/v1/rooms.banUser' { roomId, username };
} catch (e) {
  if (String(e.message).includes('does not match any group')) {
    // misleading text: room exists but caller cannot access it - add banner to the room
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: 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.

Common situations: Compliance/moderation roles designed with global permissions but no room membership; permission models that assume room-scoped moderation.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/371290ad00741b17. Report an issue: GitHub.