{"record":{"id":"9bd7d8f81095e411","repo":"RocketChat/Rocket.Chat","slug":"invalid-user-9bd7d8","errorCode":"Invalid User","errorMessage":"Invalid User","messagePattern":"Invalid User","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/integrations/outgoing/addOutgoingIntegration.ts","lineNumber":82,"sourceCode":"\tconst { insertedId } = await Integrations.insertOne(removeEmpty(integrationData));\n\n\tconst integrationStored = await Integrations.findOne({ _id: insertedId });\n\n\tif (!integrationStored) {\n\t\tthrow new Error('Error inserting integration');\n\t}\n\n\tvoid notifyOnIntegrationChanged({ ...integrationStored, _id: insertedId }, 'inserted');\n\n\treturn integrationStored as IOutgoingIntegration;\n};\n\nMeteor.methods<ServerMethods>({\n\tasync addOutgoingIntegration(integration: INewOutgoingIntegration): Promise<IOutgoingIntegration> {\n\t\tmethodDeprecationLogger.method('addOutgoingIntegration', '9.0.0', '/v1/integrations.create');\n\t\tconst { userId } = this;\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('Invalid User');\n\t\t}\n\n\t\treturn addOutgoingIntegration(userId, integration);\n\t},\n});\n","sourceCodeStart":64,"sourceCodeEnd":88,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/integrations/outgoing/addOutgoingIntegration.ts#L64-L88","documentation":"The Meteor method wrapper for addOutgoingIntegration throws Meteor.Error('Invalid User') when this.userId is falsy — the DDP call came from a connection without an authenticated user. Unlike sibling methods it carries no details object and the code string doubles as the message.","triggerScenarios":"Meteor.call('addOutgoingIntegration', integration) while logged out, or with an expired login whose resume did not bind a user to the connection.","commonSituations":"Automation scripts invoking DDP directly; integrations admin page after session expiry; unit tests that forget to stub a user on the method context.","solutions":["Authenticate and retry the method call","Use POST /v1/integrations.create with X-Auth-Token/X-User-Id headers for programmatic access","In server-side tests, stub the user context before invoking the method"],"exampleFix":"// before\nMeteor.call('addOutgoingIntegration', integration);\n\n// after\nif (!Meteor.userId()) {\n  throw new Meteor.Error('Invalid User', 'Login required');\n}\nawait Meteor.callAsync('addOutgoingIntegration', integration);","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  throw new Meteor.Error('Invalid User', 'Login required');\n}\nawait Meteor.callAsync('addOutgoingIntegration', integration);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('addOutgoingIntegration', integration);\n} catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'Invalid User') {\n    // re-authenticate, then retry once\n    return;\n  }\n  throw err;\n}","preventionTips":["Authenticate DDP clients before invoking admin methods","Use REST /v1/integrations.create for programmatic access","In tests, stub the method user context"],"tags":["authentication","meteor-methods","integrations"],"backgroundTag":"authentication-required","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}