RocketChat/Rocket.Chat · error · Meteor.Error
error-user-not-leader
error-user-not-leader
Error message
User is not a leader
What it means
Error "User is not a leader" thrown in RocketChat/Rocket.Chat.
Source
Thrown at apps/meteor/server/meteor-methods/rooms/removeRoomLeader.ts:48
const user = await Users.findOneById(userId);
if (!user?.username) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'removeRoomLeader',
});
}
const subscription = await Subscriptions.findOneByRoomIdAndUserId(rid, user._id);
if (!subscription) {
throw new Meteor.Error('error-user-not-in-room', 'User is not in this room', {
method: 'removeRoomLeader',
});
}
if (subscription.roles && Array.isArray(subscription.roles) === true && subscription.roles.includes('leader') === false) {
throw new Meteor.Error('error-user-not-leader', 'User is not a leader', {
method: 'removeRoomLeader',
});
}
const removeRoleResponse = await Subscriptions.removeRoleById(subscription._id, 'leader');
await syncRoomRolePriorityForUserAndRoom(userId, rid, subscription.roles?.filter((r) => r !== 'leader') || []);
if (removeRoleResponse.modifiedCount) {
void notifyOnSubscriptionChangedById(subscription._id);
}
const fromUser = await Users.findOneById(fromUserId);
if (!fromUser) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'removeRoomLeader',
});
}
View on GitHub (pinned to b2c16d5842)
Solutions
- Check the subscription's roles array includes 'leader' before calling removeRoomLeader; skip the call otherwise.
- Refresh the room's leader list in the UI after any role change to avoid acting on stale data.
Example fix
const sub = await Subscriptions.findOneByRoomIdAndUserId(rid, userId);
if (sub?.roles?.includes('leader')) {
await Meteor.callAsync('removeRoomLeader', rid, userId);
} When it happens
Trigger: Thrown by `removeRoomLeader` (removeRoomLeader.ts:48) when the target user's subscription has a roles array that does not include 'leader', i.e. the user is a room member but does not currently hold the leader role.
Common situations: Leader role was already removed; user was never a leader; concurrent role changes.
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/ab7d2e5ba8259c99.
Report an issue: GitHub.