RocketChat/Rocket.Chat · error · Meteor.Error

error-user-is-federated

error-user-is-federated

Error message

Cannot change federated users status

What it means

setUserActiveStatus refuses to change the active status of federated users: isUserFederated(user) is true when the user document has federated === true (accounts homed on another server in a Rocket.Chat federation). The lifecycle of such users is controlled by their home server, so local activation/deactivation is blocked.

Source

Thrown at apps/meteor/server/lib/users/setUserActiveStatus.ts:68

}

export async function setUserActiveStatus(
	userId: string,
	active: boolean,
	confirmRelinquish = false,
	executedBy?: string,
): Promise<boolean | undefined> {
	check(userId, String);
	check(active, Boolean);

	const user = await Users.findOneById(userId);

	if (!user) {
		return false;
	}

	if (isUserFederated(user)) {
		throw new Meteor.Error('error-user-is-federated', 'Cannot change federated users status', {
			method: 'setUserActiveStatus',
		});
	}

	// Users without username can't do anything, so there is no need to check for owned rooms
	if (user.username != null && !active) {
		const userAdmin = await Users.findOneAdmin(userId || '');
		const adminsCount = await Users.countActiveUsersInRoles(['admin']);
		if (userAdmin && adminsCount === 1) {
			throw new Meteor.Error('error-action-not-allowed', 'Leaving the app without an active admin is not allowed', {
				method: 'removeUserFromRole',
				action: 'Remove_last_admin',
			});
		}

		const subscribedRooms = await getSubscribedRoomsForUserWithDetails(userId);
		// give omnichannel rooms a special treatment :)
		const chatSubscribedRooms = subscribedRooms.filter(({ t }) => t !== 'l');

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Manage the user's active status on their home server in the federation.
  2. Filter federated users (federated === true) out of bulk deactivation/activation scripts.
  3. If this user should be local, review your federation setup and the user's origin before attempting local changes.

Example fix

// before
for (const uid of allUserIds) {
  await setUserActiveStatus(uid, false); // throws on federated users
}

// after
for (const uid of allUserIds) {
  const user = await Users.findOneById(uid);
  if (user?.federated === true) continue; // skip federated users
  await setUserActiveStatus(uid, false);
}
Defensive patterns

Strategy: validation

Validate before calling

const user = await Users.findOneById(userId, { projection: { federated: 1 } });
if (user && 'federated' in user && user.federated === true) {
  throw new Meteor.Error('error-user-is-federated', 'Cannot change federated users status');
}
await setUserActiveStatus(userId, active, confirmRelinquish);

Type guard

import type { IUser } from '@rocket.chat/core-typings';

const isFederatedUser = (user: Partial<IUser>): boolean =>
  'federated' in user && (user as { federated?: boolean }).federated === true;

Prevention

When it happens

Trigger: Calling setUserActiveStatus (the users.deactivate / users.activate endpoints route here) for a user whose document has federated: true — i.e., a colleague from another federated server appearing in your user directory.

Common situations: Admin tries to deactivate a federated user from the local admin console; bulk user-management/offboarding scripts iterate all users without filtering out federated ones; federation was enabled and the directory now mixes local and federated accounts.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/8bb30458a02e3531. Report an issue: GitHub.