{"record":{"id":"cb5c813d8d6ba7d2","repo":"RocketChat/Rocket.Chat","slug":"error-username-reserved-by-bridge","errorCode":"error-username-reserved-by-bridge","errorMessage":"Name is reserved by a federation bridge","messagePattern":"Name is reserved by a federation bridge","errorType":"error_code","errorClass":"MeteorError","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/hooks/federation/index.ts","lineNumber":393,"sourceCode":"\t\treturn;\n\t}\n\n\tif ('name' in userUpdated && userUpdated.name !== oldUserData.name) {\n\t\tvoid FederationMatrix.updateUserName(userUpdated);\n\t}\n});\n\n// Reserve handles that fall within a bridge's exclusive namespace, so a regular user cannot\n// register or rename into a localpart only the bridge is allowed to own. Usernames are checked\n// against the bridge's exclusive `users` namespace; room/team names against its `aliases`/`rooms`\n// namespaces. Inert when federation is disabled (the helper matches against loaded appservice\n// registrations, of which there are none). Every handle assignment path — user creation,\n// SSO/LDAP assignment and renames, plus room renames and team creation — funnels through\n// `checkUsernameAvailability`.\ncheckUsernameAvailabilityCallback.add(\n\t(name, type) => {\n\t\tif (isReservedByExclusiveBridge(type, name)) {\n\t\t\tthrow new MeteorError('error-username-reserved-by-bridge', 'Name is reserved by a federation bridge');\n\t\t}\n\t},\n\tcallbacks.priority.HIGH,\n\t'federation-bridge-namespace',\n);\n","sourceCodeStart":375,"sourceCodeEnd":399,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/hooks/federation/index.ts#L375-L399","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Choose a username/room name outside the bridge's reserved pattern (check the appservice registration's exclusive namespace regexes)","If the collision is a false positive, tighten the bridge's namespace regex in its appservice registration","If the name genuinely belongs to that service, provision it through the bridge itself rather than as a regular user"],"exampleFix":"// before: registering a name and getting error-username-reserved-by-ridge from the callback\nawait setUsername(userId, '_bridge_alice');\n\n// after: test the same reservation rule first\nimport { isReservedByExclusiveBridge } from '@rocket.chat/federation-matrix';\nif (isReservedByExclusiveBridge('user', '_bridge_alice')) {\n  throw new Error('Pick a name outside the bridge namespace');\n}\nawait setUsername(userId, '_bridge_alice');","handlingStrategy":"validation","validationCode":"import { isReservedByExclusiveBridge } from '@rocket.chat/federation-matrix';\n\nconst isHandleAvailable = (type: 'user' | 'room', name: string): boolean =>\n  !isReservedByExclusiveBridge(type, name);","typeGuard":null,"tryCatchPattern":"try {\n  await setUsername(userId, name);\n} catch (err: any) {\n  if (err?.error === 'error-username-reserved-by-bridge') {\n    // prompt for a different name outside the bridge namespace\n  }\n  throw err;\n}","preventionTips":["Check bridge-exclusive namespaces in username suggestion/validation UIs","Keep appservice namespace regexes narrow so common names are not over-reserved","Remember the check is case-insensitive (lowercased localpart is also tested)"],"tags":["federation","matrix-bridge","usernames","namespace-conflict"],"backgroundTag":"reserved-username","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}