RocketChat/Rocket.Chat · error · Meteor.Error
error-user-not-in-room
error-user-not-in-room
Error message
User is not in this room
What it means
Thrown by the `unmuteUserInRoom` Meteor method when `Subscriptions.findOneByRoomIdAndUsername(data.rid, data.username)` returns null, i.e. the user you are trying to unmute has no subscription document in the target room. The method first checks that the room type allows the MUTE member action, then requires the target to actually be a member. Since there is no membership record, there is nothing to unmute and the whole operation is aborted before any DB write.
Source
Thrown at apps/meteor/server/meteor-methods/rooms/unmuteUserInRoom.ts:46
if (!room) {
throw new Meteor.Error('error-invalid-room', 'Invalid room', {
method: 'unmuteUserInRoom',
});
}
if (!(await roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.MUTE, fromId))) {
throw new Meteor.Error('error-invalid-room-type', `${room.t} is not a valid room type`, {
method: 'unmuteUserInRoom',
type: room.t,
});
}
const subscription = await Subscriptions.findOneByRoomIdAndUsername(data.rid, data.username, {
projection: { _id: 1 },
});
if (!subscription) {
throw new Meteor.Error('error-user-not-in-room', 'User is not in this room', {
method: 'unmuteUserInRoom',
});
}
const unmutedUser = await Users.findOneByUsernameIgnoringCase(data.username);
if (!unmutedUser?.username) {
throw new Meteor.Error('error-invalid-user', 'Invalid user to unmute', {
method: 'unmuteUserInRoom',
});
}
const fromUser = await Users.findOneById(fromId);
if (!fromUser) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'unmuteUserInRoom',
});
}
View on GitHub (pinned to b2c16d5842)
Solutions
- Re-fetch the current room members before showing the unmute action, and only enable it for users still subscribed.
- Verify the subscription first (server-side `Subscriptions.findOneByRoomIdAndUsername(rid, username)`, or the room members data on the client).
- Pass the username exactly as recorded on the subscription (`sub.u.username`) instead of a possibly renamed copy.
- In UI code, treat this error as benign: toast 'user is not in this room' and refresh the room state.
Example fix
// before
Meteor.call('unmuteUserInRoom', { rid, username });
// after - only unmute current members, using the subscribed username
const sub = Subscriptions.findOne({ rid, 'u.username': username });
if (!sub) {
// stale UI: user already left the room - refresh members and skip
return;
}
Meteor.call('unmuteUserInRoom', { rid, username: sub.u.username }); Defensive patterns
Strategy: validation
Validate before calling
// server-side: confirm membership before unmuting
const isRoomMember = async (rid: string, username: string) =>
Boolean(await Subscriptions.findOneByRoomIdAndUsername(rid, username, { projections: { _id: 1 } }));
if (await isRoomMember(rid, username)) {
await Meteor.callAsync('unmuteUserInRoom', { rid, username });
} Type guard
const isRoomMember = (rid: string, username: string): boolean =>
!!Subscriptions.findOne({ rid, 'u.username': username }, { fields: { _id: 1 } }); Try / catch
try {
await Meteor.callAsync('unmuteUserInRoom', { rid, username });
} catch (e: any) {
if (e?.error === 'error-user-not-in-room') {
// benign: target already left the room - refresh the member list and continue
return;
}
throw e;
} Prevention
- Render unmute actions from live subscription/member data, not cached lists.
- After any removeUser/leaveRoom flow, clear pending moderation actions for that user.
- Pass usernames taken from the subscription record to survive renames and casing differences.
When it happens
Trigger: Calling `Meteor.call('unmuteUserInRoom', { rid, username })` where `username` is not subscribed to `rid`: the target user left or was kicked/removed from the room, the client member list is stale and still renders an unmute action, or the username passed does not exactly match the username stored on the subscription (e.g. after a rename).
Common situations: Stale room member UI after another moderator removes the user; race between a kick and an unmute from two admins; moderation bots unmuting by cached username after the user was removed; usernames renamed between the action trigger and the method call.
Related errors
- User is not in this room
- User is already banned from this room
- error-invalid-room
- error-user-is-banned
- error-invalid-subscription
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/d55bbb261314610f.
Report an issue: GitHub.