{"record":{"id":"e3423eaa0bf54e13","repo":"RocketChat/Rocket.Chat","slug":"federation-configuration-is-invalid-unable-to-chan-e3423e","errorCode":null,"errorMessage":"Federation configuration is invalid,unable to change room owners","messagePattern":"Federation configuration is invalid,unable to change room owners","errorType":"exception","errorClass":"FederationMatrixInvalidConfigurationError","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/rooms/addRoomOwner.ts","lineNumber":44,"sourceCode":"\tcheck(userId, String);\n\n\tconst room = await Rooms.findOneById(rid, { projection: { t: 1, federated: 1, federation: 1 } });\n\tif (!room) {\n\t\tthrow new Meteor.Error('error-invalid-room', 'Invalid room', {\n\t\t\tmethod: 'addRoomOwner',\n\t\t});\n\t}\n\n\tconst isFederated = isRoomFederated(room);\n\n\tif (!(await hasPermissionAsync(fromUserId, 'set-owner', rid)) && !isFederated) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', {\n\t\t\tmethod: 'addRoomOwner',\n\t\t});\n\t}\n\n\tif (isFederated && !isFederationEnabled()) {\n\t\tthrow new FederationMatrixInvalidConfigurationError('unable to change room owners');\n\t}\n\n\tconst user = await Users.findOneById(userId);\n\n\tif (!user?.username) {\n\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\tmethod: 'addRoomOwner',\n\t\t});\n\t}\n\n\tconst subscription = await Subscriptions.findOneByRoomIdAndUserId(rid, user._id);\n\n\tif (!subscription) {\n\t\tthrow new Meteor.Error('error-user-not-in-room', 'User is not in this room', {\n\t\t\tmethod: 'addRoomOwner',\n\t\t});\n\t}\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/rooms/addRoomOwner.ts#L26-L62","documentation":"Thrown by addRoomOwner() in apps/meteor/server/meteor-methods/rooms/addRoomOwner.ts:44 as FederationMatrixInvalidConfigurationError('unable to change room owners') — a plain Error subclass (apps/meteor/server/services/federation/utils.ts:13) whose message becomes 'Federation configuration is invalid,unable to change room owners'. It fires when the room is federated (isRoomFederated(room) === true, bypassing the permission check) but the Federation_Service_Enabled setting is false, so the server cannot perform the Matrix-side ownership change.","triggerScenarios":"Calling addRoomOwner on a room whose federation fields mark it as federated while the workspace has federation disabled in Administration > Federation (Federation_Service_Enabled = false); federation was enabled when the room was created and later turned off; importing/migrating federated rooms into a workspace where the Federation service was never configured.","commonSituations":"Disabling federation after federated rooms exist and then trying to manage their owners; test environments cloning federated room documents without the federation service; partial federation setup where the app flag is on but the server setting is off.","solutions":["Re-enable federation: set Federation_Service_Enabled to true in Administration > Federation (or settings.get('Federation_Service_Enabled')).","If the room should no longer be federated, use the supported un-federation/migration flow to clear its federation state before changing owners.","Guard the call: if (isRoomFederated(room) && !settings.get('Federation_Service_Enabled')) skip or surface a configuration error to the operator.","If federation is intentionally off workspace-wide, audit for stray federated rooms (rooms with federation/federated markers) and clean them up."],"exampleFix":"// before\nawait addRoomOwner(uid, rid, targetUserId); // throws on federated room with federation off\n\n// after\nconst federationEnabled = settings.get<boolean>('Federation_Service_Enabled');\nif (!federationEnabled) throw new Error('enable Federation_Service_Enabled before changing owners of federated rooms');\nawait addRoomOwner(uid, rid, targetUserId);","handlingStrategy":"try-catch","validationCode":"import { isFederationEnabled } from '<server>/services/federation/utils';\nif (!isFederationEnabled()) {\n  // changing owners of federated rooms will throw\n  throw new Error('enable federation before managing federated room owners');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await addRoomOwner(uid, rid, userId);\n} catch (e) {\n  if (e instanceof Error && e.name === 'FederationMatrixInvalidConfiguration') {\n    // configuration problem, not a code problem: check Federation_Service_Enabled\n  }\n}","preventionTips":["Monitor the Federation_Service_Enabled setting and alert when it flips while federated rooms exist.","Guard owner-change flows on federated rooms with an explicit settings check.","Treat e.name === 'FederationMatrixInvalidConfiguration' as an ops/config error class in your handler."],"tags":["federation","matrix","settings","rooms","configuration"],"backgroundTag":"federation-not-enabled","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}