RocketChat/Rocket.Chat · error · MeteorError

error-username-reserved-by-bridge

error-username-reserved-by-bridge

Error message

Name is reserved by a federation bridge

What it means

Thrown by the checkUsernameAvailability callback (priority HIGH, 'federation-bridge-namespace') when a requested username or room/team name falls inside a Matrix appservice bridge's exclusive namespace. Exclusive namespaces may only be owned by the bridge (e.g. a WhatsApp/Slack bridge owning @whatsapp_*:server.com), so regular users cannot register or rename into them. The check is inert when federation is not configured (no serverName / no appservice registrations loaded).

Solutions

  1. Choose a username/room name outside the bridge's reserved pattern (check the appservice registration's exclusive namespace regexes)
  2. If the collision is a false positive, tighten the bridge's namespace regex in its appservice registration
  3. If the name genuinely belongs to that service, provision it through the bridge itself rather than as a regular user

Example fix

// before: registering a name and getting error-username-reserved-by-ridge from the callback
await setUsername(userId, '_bridge_alice');

// after: test the same reservation rule first
import { isReservedByExclusiveBridge } from '@rocket.chat/federation-matrix';
if (isReservedByExclusiveBridge('user', '_bridge_alice')) {
  throw new Error('Pick a name outside the bridge namespace');
}
await setUsername(userId, '_bridge_alice');
Defensive patterns

Strategy: validation

Validate before calling

import { isReservedByExclusiveBridge } from '@rocket.chat/federation-matrix';

const isHandleAvailable = (type: 'user' | 'room', name: string): boolean =>
  !isReservedByExclusiveBridge(type, name);

Try / catch

try {
  await setUsername(userId, name);
} catch (err: any) {
  if (err?.error === 'error-username-reserved-by-bridge') {
    // prompt for a different name outside the bridge namespace
  }
  throw err;
}

Prevention

When it happens

Trigger: Registering or renaming a user whose username matches an exclusive 'users' namespace regex; creating/renaming a room or team whose name matches the bridge's 'aliases'/'rooms' namespaces; names are also tested lowercased because Matrix localparts are lowercase-conventioned.

Common situations: Bridges (Element/Matrix appservices) installed with broad exclusive namespace regexes like @_bridge_.*; users picking nicknames that collide with the bridge prefix; renaming teams into a reserved alias pattern.

Related errors


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

Appendix: source

Thrown at apps/meteor/ee/server/hooks/federation/index.ts:393

		return;
	}

	if ('name' in userUpdated && userUpdated.name !== oldUserData.name) {
		void FederationMatrix.updateUserName(userUpdated);
	}
});

// Reserve handles that fall within a bridge's exclusive namespace, so a regular user cannot
// register or rename into a localpart only the bridge is allowed to own. Usernames are checked
// against the bridge's exclusive `users` namespace; room/team names against its `aliases`/`rooms`
// namespaces. Inert when federation is disabled (the helper matches against loaded appservice
// registrations, of which there are none). Every handle assignment path — user creation,
// SSO/LDAP assignment and renames, plus room renames and team creation — funnels through
// `checkUsernameAvailability`.
checkUsernameAvailabilityCallback.add(
	(name, type) => {
		if (isReservedByExclusiveBridge(type, name)) {
			throw new MeteorError('error-username-reserved-by-bridge', 'Name is reserved by a federation bridge');
		}
	},
	callbacks.priority.HIGH,
	'federation-bridge-namespace',
);

View on GitHub (pinned to b2c16d5842)