{"record":{"id":"14f204e8fa5f8e67","repo":"RocketChat/Rocket.Chat","slug":"error-direct-message-room","errorCode":"error-direct-message-room","errorMessage":"rooms type: ${room.t} can not be archived","messagePattern":"rooms type: (.+?) can not be archived","errorType":"error_code","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/rooms/archiveRoom.ts","lineNumber":34,"sourceCode":"\t\tarchiveRoom(rid: string): Promise<void>;\n\t}\n}\n\nexport const executeArchiveRoom = async (userId: string, rid: string) => {\n\tcheck(rid, String);\n\n\tconst user = await Users.findOneById(userId, { projection: { username: 1, name: 1 } });\n\tif (!user || !isRegisterUser(user)) {\n\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'archiveRoom' });\n\t}\n\n\tconst room = await Rooms.findOneById(rid);\n\tif (!room) {\n\t\tthrow new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'archiveRoom' });\n\t}\n\n\tif (!(await roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.ARCHIVE, userId))) {\n\t\tthrow new Meteor.Error('error-direct-message-room', `rooms type: ${room.t} can not be archived`, { method: 'archiveRoom' });\n\t}\n\n\tif (!(await hasPermissionAsync(userId, 'archive-room', room._id))) {\n\t\tthrow new Meteor.Error('error-not-authorized', 'Not authorized', { method: 'archiveRoom' });\n\t}\n\n\treturn archiveRoom(rid, user);\n};\n\nMeteor.methods<ServerMethods>({\n\tasync archiveRoom(rid) {\n\t\tmethodDeprecationLogger.method('archiveRoom', '9.0.0', '/v1/channels.archive');\n\t\tconst userId = Meteor.userId();\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'archiveRoom' });\n\t\t}\n\n\t\treturn executeArchiveRoom(userId, rid);","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/rooms/archiveRoom.ts#L16-L52","documentation":"Thrown when the room exists but its type coordinator refuses the ARCHIVE member action: roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.ARCHIVE, userId) returned false. Despite the legacy code error-direct-message-room, this guards every room type, not only direct messages - any type whose directives do not allow archiving for this user lands here.","triggerScenarios":"Archiving a direct-message room (t='d'); archiving room types whose directives do not register the ARCHIVE member action for the caller; custom room types (apps/forks) whose coordinator omits allowMemberAction for ARCHIVE.","commonSituations":"UIs that enable archive for every listed room including DMs; scripts walking all subscriptions and archiving every rid; custom room types added without archive support.","solutions":["Filter the archive action by room type before invoking: stock archivable types are 'c' (channel) and 'p' (private group).","For direct messages, use hide/close conversation instead of archive.","If you maintain a custom room type, implement allowMemberAction for RoomMemberActions.ARCHIVE in its coordinator."],"exampleFix":"// before\nMeteor.call('archiveRoom', room._id); // fires for DMs too\n\n// after\nconst isArchivable = (t: string) => t === 'c' || t === 'p';\nif (isArchivable(room.t)) {\n  Meteor.call('archiveRoom', room._id);\n} else {\n  Meteor.call('hideRoom', room._id);\n}","handlingStrategy":"type-guard","validationCode":"const room = roomsCollection.findOne({ _id: rid }, { fields: { t: 1 } });\nif (room && !isArchivableRoom(room)) {\n  // this room type cannot be archived - offer hide/close instead\n}","typeGuard":"const isArchivableRoom = (room: { t: string }): room is { t: 'c' | 'p' } =>\n  room.t === 'c' || room.t === 'p';","tryCatchPattern":"try {\n  await Meteor.callAsync('archiveRoom', rid);\n} catch (e) {\n  if (e instanceof Meteor.Error && e.error === 'error-direct-message-room') {\n    // room type does not support archive - hide the conversation instead\n    await Meteor.callAsync('hideRoom', rid);\n    return;\n  }\n  throw e;\n}","preventionTips":["Gate the archive action on room type (only 'c'/'p' for stock types).","Remember the legacy error code covers every non-archivable type, not just direct messages.","Keep custom room-type directives in sync with the client capability checks that reveal the archive action."],"tags":["rocket-chat","meteor","ddp","archive-room","room-type","direct-message"],"backgroundTag":"unsupported-room-type","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}