{"record":{"id":"8da44f012b05813b","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-room-8da44f","errorCode":"error-invalid-room","errorMessage":"Invalid room","messagePattern":"Invalid room","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/rooms/unarchiveRoom.ts","lineNumber":29,"sourceCode":"declare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tunarchiveRoom(rid: string): Promise<void>;\n\t}\n}\n\nexport const executeUnarchiveRoom = 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\n\tif (!room) {\n\t\tthrow new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'unarchiveRoom' });\n\t}\n\n\tif (!(await hasPermissionAsync(userId, 'unarchive-room', room._id))) {\n\t\tthrow new Meteor.Error('error-not-authorized', 'Not authorized', { method: 'unarchiveRoom' });\n\t}\n\n\treturn unarchiveRoom(rid, user);\n};\n\nMeteor.methods<ServerMethods>({\n\tasync unarchiveRoom(rid) {\n\t\tmethodDeprecationLogger.method('unarchiveRoom', '9.0.0', '/v1/channels.unarchive');\n\t\tconst userId = Meteor.userId();\n\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'unarchiveRoom' });\n\t\t}\n","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/rooms/unarchiveRoom.ts#L11-L47","documentation":"unarchiveRoom loads the room with Rooms.findOneById(rid); a null result throws error-invalid-room. The id must identify an existing room document in the connected database before any unarchive logic runs.","triggerScenarios":"Calling unarchiveRoom with the id of a deleted room, an id from another workspace or environment, or a malformed/truncated id string.","commonSituations":"Attempting to restore a room that was permanently removed instead of archived; stale rid in admin tooling; connected to the wrong database after a migration.","solutions":["Confirm the room exists (Rooms.findOneById, or REST rooms.info) before unarchiving","If the room was deleted rather than archived, restore it from trash/backup instead of calling unarchive","Check the id source and the connected database when ids systematically fail to resolve","Verify the room is actually archived — unarchive is only meaningful for archived rooms"],"exampleFix":"// before\nawait executeUnarchiveRoom(userId, rid); // rid no longer exists\n\n// after\nconst room = await Rooms.findOneById(rid, { projection: { _id: 1, archived: 1 } });\nif (!room) throw new Meteor.Error('error-invalid-room', 'Invalid room');\nawait executeUnarchiveRoom(userId, room._id);","handlingStrategy":"validation","validationCode":"const room = await Rooms.findOneById(rid, { projection: { _id: 1, archived: 1 } });\nif (!room) {\n  // rid does not resolve: refresh it or stop before calling unarchiveRoom\n}","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('unarchiveRoom', rid);\n} catch (error) {\n  if (error instanceof Meteor.Error && error.error === 'error-invalid-room') {\n    // room gone: clear stale state; if it was deleted (not archived) restore via trash/backup\n  }\n}","preventionTips":["Resolve rooms by id right before acting on them; do not cache rids across sessions","Distinguish archived rooms (unarchive works) from deleted rooms (restore path)","Verify environment/database when ids stop resolving"],"tags":["rooms","not-found","meteor-methods"],"backgroundTag":"room-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}