RocketChat/Rocket.Chat · error · Meteor.Error
Invalid User
Invalid User
Error message
Invalid User
What it means
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.
Source
Thrown at apps/meteor/server/meteor-methods/integrations/outgoing/addOutgoingIntegration.ts:82
const { insertedId } = await Integrations.insertOne(removeEmpty(integrationData));
const integrationStored = await Integrations.findOne({ _id: insertedId });
if (!integrationStored) {
throw new Error('Error inserting integration');
}
void notifyOnIntegrationChanged({ ...integrationStored, _id: insertedId }, 'inserted');
return integrationStored as IOutgoingIntegration;
};
Meteor.methods<ServerMethods>({
async addOutgoingIntegration(integration: INewOutgoingIntegration): Promise<IOutgoingIntegration> {
methodDeprecationLogger.method('addOutgoingIntegration', '9.0.0', '/v1/integrations.create');
const { userId } = this;
if (!userId) {
throw new Meteor.Error('Invalid User');
}
return addOutgoingIntegration(userId, integration);
},
});
View on GitHub (pinned to b2c16d5842)
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
Example fix
// before
Meteor.call('addOutgoingIntegration', integration);
// after
if (!Meteor.userId()) {
throw new Meteor.Error('Invalid User', 'Login required');
}
await Meteor.callAsync('addOutgoingIntegration', integration); Defensive patterns
Strategy: validation
Validate before calling
if (!Meteor.userId()) {
throw new Meteor.Error('Invalid User', 'Login required');
}
await Meteor.callAsync('addOutgoingIntegration', integration); Try / catch
try {
await Meteor.callAsync('addOutgoingIntegration', integration);
} catch (err) {
if (err instanceof Meteor.Error && err.error === 'Invalid User') {
// re-authenticate, then retry once
return;
}
throw err;
} Prevention
- Authenticate DDP clients before invoking admin methods
- Use REST /v1/integrations.create for programmatic access
- In tests, stub the method user context
When it happens
Trigger: Meteor.call('addOutgoingIntegration', integration) while logged out, or with an expired login whose resume did not bind a user to the connection.
Common situations: Automation scripts invoking DDP directly; integrations admin page after session expiry; unit tests that forget to stub a user on the method context.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/9bd7d8f81095e411.
Report an issue: GitHub.