{"record":{"id":"ce7b53510b419bfa","repo":"RocketChat/Rocket.Chat","slug":"error-cannot-delete-federated-room","errorCode":"error-cannot-delete-federated-room","errorMessage":"Cannot delete federated room","messagePattern":"Cannot delete federated room","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/eraseRoom.ts","lineNumber":21,"sourceCode":"import type { IRoom, IUser, AtLeast } from '@rocket.chat/core-typings';\nimport { Rooms } from '@rocket.chat/models';\nimport { Meteor } from 'meteor/meteor';\n\nimport { hasPermissionAsync } from './authorization/hasPermission';\nimport { deleteRoom } from './rooms/deleteRoom';\nimport { roomCoordinator } from './rooms/roomCoordinator';\n\nexport async function eraseRoom(roomOrId: string | IRoom, user: AtLeast<IUser, '_id' | 'name' | 'username' | 'roles'>): Promise<void> {\n\tconst room = typeof roomOrId === 'string' ? await Rooms.findOneById(roomOrId) : roomOrId;\n\n\tif (!room) {\n\t\tthrow new Meteor.Error('error-invalid-room', 'Invalid room', {\n\t\t\tmethod: 'eraseRoom',\n\t\t});\n\t}\n\n\tif (room.federated) {\n\t\tthrow new Meteor.Error('error-cannot-delete-federated-room', 'Cannot delete federated room', {\n\t\t\tmethod: 'eraseRoom',\n\t\t});\n\t}\n\n\tif (\n\t\t!(await roomCoordinator\n\t\t\t.getRoomDirectives(room.t)\n\t\t\t?.canBeDeleted((permissionId, rid) => hasPermissionAsync(user, permissionId, rid), room))\n\t) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', {\n\t\t\tmethod: 'eraseRoom',\n\t\t});\n\t}\n\n\tconst team = room.teamId && (await Team.getOneById(room.teamId, { projection: { roomId: 1 } }));\n\tif (team && !(await hasPermissionAsync(user, `delete-team-${room.t === 'c' ? 'channel' : 'group'}`, team.roomId))) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', {\n\t\t\tmethod: 'eraseRoom',","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/eraseRoom.ts#L3-L39","documentation":"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.","triggerScenarios":"Calling eraseRoom on any room whose document has federated === true — rooms created or joined through the federation feature.","commonSituations":"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.","solutions":["Do not delete federated rooms locally — manage participation/removal through federation tooling instead","Filter federated rooms out of any bulk-delete automation before calling eraseRoom"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const room = typeof roomOrId === 'string' ? await Rooms.findOneById(roomOrId) : roomOrId;\nif (room?.federated) {\n  // hide/disable local delete and inform the user federated rooms cannot be erased\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter federated rooms out of bulk-delete tooling before calling eraseRoom","Communicate that federated rooms are managed via federation, not local deletion"],"tags":["rooms","federation","deletion"],"backgroundTag":"operation-not-supported","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}