RocketChat/Rocket.Chat · error · Meteor.Error

error-cannot-delete-federated-room

error-cannot-delete-federated-room

Error message

Cannot delete federated room

What it means

eraseRoom refuses to delete rooms flagged federated: federated rooms span multiple servers, and locally erasing one would corrupt the federated room graph. The check runs after the room-exists check and before permission checks.

Source

Thrown at apps/meteor/server/lib/eraseRoom.ts:21

import type { IRoom, IUser, AtLeast } from '@rocket.chat/core-typings';
import { Rooms } from '@rocket.chat/models';
import { Meteor } from 'meteor/meteor';

import { hasPermissionAsync } from './authorization/hasPermission';
import { deleteRoom } from './rooms/deleteRoom';
import { roomCoordinator } from './rooms/roomCoordinator';

export async function eraseRoom(roomOrId: string | IRoom, user: AtLeast<IUser, '_id' | 'name' | 'username' | 'roles'>): Promise<void> {
	const room = typeof roomOrId === 'string' ? await Rooms.findOneById(roomOrId) : roomOrId;

	if (!room) {
		throw new Meteor.Error('error-invalid-room', 'Invalid room', {
			method: 'eraseRoom',
		});
	}

	if (room.federated) {
		throw new Meteor.Error('error-cannot-delete-federated-room', 'Cannot delete federated room', {
			method: 'eraseRoom',
		});
	}

	if (
		!(await roomCoordinator
			.getRoomDirectives(room.t)
			?.canBeDeleted((permissionId, rid) => hasPermissionAsync(user, permissionId, rid), room))
	) {
		throw new Meteor.Error('error-not-allowed', 'Not allowed', {
			method: 'eraseRoom',
		});
	}

	const team = room.teamId && (await Team.getOneById(room.teamId, { projection: { roomId: 1 } }));
	if (team && !(await hasPermissionAsync(user, `delete-team-${room.t === 'c' ? 'channel' : 'group'}`, team.roomId))) {
		throw new Meteor.Error('error-not-allowed', 'Not allowed', {
			method: 'eraseRoom',

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Do not delete federated rooms locally — manage participation/removal through federation tooling instead
  2. Filter federated rooms out of any bulk-delete automation before calling eraseRoom
Defensive patterns

Strategy: validation

Validate before calling

const room = typeof roomOrId === 'string' ? await Rooms.findOneById(roomOrId) : roomOrId;
if (room?.federated) {
  // hide/disable local delete and inform the user federated rooms cannot be erased
}

Prevention

When it happens

Trigger: Calling eraseRoom on any room whose document has federated === true — rooms created or joined through the federation feature.

Common situations: Admins attempting to clean up federated channels with the normal delete flow; federation enabled and rooms created by federated peers; tooling/scripts that bulk-erase rooms without filtering federated ones.

Related errors


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