{"record":{"id":"4db250ae0d3c6c9c","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-room-4db250","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/unmuteUserInRoom.ts","lineNumber":29,"sourceCode":"\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tunmuteUserInRoom(data: { rid: IRoom['_id']; username: string }): boolean;\n\t}\n}\n\nexport const unmuteUserInRoom = async (fromId: string, data: { rid: IRoom['_id']; username: string }): Promise<boolean> => {\n\tif (!fromId || !(await hasPermissionAsync(fromId, 'mute-user', data.rid))) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', {\n\t\t\tmethod: 'unmuteUserInRoom',\n\t\t});\n\t}\n\n\tconst room = await Rooms.findOneById(data.rid);\n\n\tif (!room) {\n\t\tthrow new Meteor.Error('error-invalid-room', 'Invalid room', {\n\t\t\tmethod: 'unmuteUserInRoom',\n\t\t});\n\t}\n\n\tif (!(await roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.MUTE, fromId))) {\n\t\tthrow new Meteor.Error('error-invalid-room-type', `${room.t} is not a valid room type`, {\n\t\t\tmethod: 'unmuteUserInRoom',\n\t\t\ttype: room.t,\n\t\t});\n\t}\n\n\tconst subscription = await Subscriptions.findOneByRoomIdAndUsername(data.rid, data.username, {\n\t\tprojection: { _id: 1 },\n\t});\n\n\tif (!subscription) {\n\t\tthrow new Meteor.Error('error-user-not-in-room', 'User is not in this room', {\n\t\t\tmethod: 'unmuteUserInRoom',","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/rooms/unmuteUserInRoom.ts#L11-L47","documentation":"unmuteUserInRoom loads the room with Rooms.findOneById(data.rid); a null result throws error-invalid-room before any moderation logic or permission checks on the target run.","triggerScenarios":"Calling unmuteUserInRoom with the id of a deleted or nonexistent room, an id from another workspace, or a typo'd/malformed rid.","commonSituations":"Moderation UI acting on a room deleted moments earlier; stale room ids cached in integrations or bots; ids that lost characters when copied.","solutions":["Verify the room exists before invoking (REST rooms.info or the rooms collection on the server)","Refresh room ids in long-lived integrations instead of caching them indefinitely","Treat error-invalid-room from moderation methods as 'room gone' and clean up the UI/integration state"],"exampleFix":"// before\nMeteor.call('unmuteUserInRoom', { rid, username }); // rid was deleted\n\n// after\nconst room = await Rooms.findOneById(rid, { projection: { _id: 1 } });\nif (!room) {\n  // refresh state; do not call the method\n} else {\n  Meteor.call('unmuteUserInRoom', { rid: room._id, username });\n}","handlingStrategy":"validation","validationCode":"const room = await Rooms.findOneById(rid, { projection: { _id: 1 } });\nif (!room) {\n  // room no longer exists: refresh state instead of calling unmuteUserInRoom\n}","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('unmuteUserInRoom', { rid, username });\n} catch (error) {\n  if (error instanceof Meteor.Error && error.error === 'error-invalid-room') {\n    // room gone: discard the moderation action and update UI state\n  }\n}","preventionTips":["Look up the room immediately before moderation actions; rooms can vanish between render and click","Evict deleted rooms from cached lists and menus","In integrations, re-resolve rids per operation rather than caching forever"],"tags":["rooms","not-found","meteor-methods"],"backgroundTag":"room-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}