{"record":{"id":"e733b68ce0e62c92","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-e733b6","errorCode":"error-invalid-user","errorMessage":"Invalid user","messagePattern":"Invalid user","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/platform/checkFederationConfiguration.ts","lineNumber":18,"sourceCode":"import { Federation, FederationEE, Authorization } from '@rocket.chat/core-services';\nimport type { ServerMethods } from '@rocket.chat/ddp-client';\nimport { License } from '@rocket.chat/license';\nimport { Meteor } from 'meteor/meteor';\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tcheckFederationConfiguration(): Promise<{ message: string }>;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync checkFederationConfiguration() {\n\t\tconst uid = Meteor.userId();\n\n\t\tif (!uid) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'checkFederationConfiguration',\n\t\t\t});\n\t\t}\n\n\t\tif (!(await Authorization.hasPermission(uid, 'view-privileged-setting'))) {\n\t\t\tthrow new Meteor.Error('error-not-allowed', 'Action not allowed', {\n\t\t\t\tmethod: 'checkFederationConfiguration',\n\t\t\t});\n\t\t}\n\n\t\tconst errors: string[] = [];\n\n\t\tconst successes: string[] = [];\n\n\t\tconst service = License.hasValidLicense() ? FederationEE : Federation;\n\n\t\tconst status = await service.configurationStatus();\n","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/platform/checkFederationConfiguration.ts#L1-L36","documentation":"checkFederationConfiguration validates the workspace's federation bridge; it first requires an authenticated user (Meteor.userId()), otherwise error-invalid-user. It is a privileged admin operation that probes homeserver/appservice connectivity.","triggerScenarios":"Invoking checkFederationConfiguration over a DDP connection without a logged-in user; an expired login token; automation calling the method without credentials.","commonSituations":"Scripts hitting admin methods without authentication; token expiry during long-lived sessions; UI invoking the check before authentication completes.","solutions":["Authenticate before calling (valid DDP login, or run the check from the logged-in admin UI)","Check Meteor.userId() client-side and re-authenticate when this error appears","For headless automation, use authenticated REST calls rather than raw Meteor methods"],"exampleFix":"// before\nMeteor.call('checkFederationConfiguration');\n\n// after\nif (!Meteor.userId()) await ensureLogin();\nconst { message } = await Meteor.callAsync('checkFederationConfiguration');","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  await ensureLogin();\n}\nconst { message } = await Meteor.callAsync('checkFederationConfiguration');","typeGuard":"const isInvalidUserError = (e: unknown): e is Meteor.Error =>\n  typeof e === 'object' && e !== null && (e as { error?: string }).error === 'error-invalid-user';","tryCatchPattern":"try {\n  await Meteor.callAsync('checkFederationConfiguration');\n} catch (e) {\n  if (isInvalidUserError(e)) {\n    await reauthenticate();\n    return Meteor.callAsync('checkFederationConfiguration');\n  }\n  throw e;\n}","preventionTips":["Reserve federation admin actions for authenticated privileged sessions","Authenticate before invoking admin methods from consoles or scripts","Centralize re-login handling for error-invalid-user across the admin UI"],"tags":["rocket-chat","meteor","authentication","federation","admin"],"backgroundTag":"user-not-authenticated","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}