RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-user
error-invalid-user
Error message
Invalid user
What it means
The removeOAuthService method wrapper throws 'error-invalid-user' when Meteor.userId() returns null — the DDP connection is not authenticated. Deprecated since 9.0.0 in favor of /v1/settings.removeCustomOAuth.
Source
Thrown at apps/meteor/server/meteor-methods/auth/removeOAuthService.ts:75
const promises = settingsIds.map((id) => Settings.removeById(id));
(await Promise.all(promises)).forEach((value, index) => {
if (value?.deletedCount) {
void notifyOnSettingChangedById(settingsIds[index], 'removed');
}
});
};
Meteor.methods<ServerMethods>({
async removeOAuthService(name) {
methodDeprecationLogger.method('removeOAuthService', '9.0.0', '/v1/settings.removeCustomOAuth');
check(name, String);
const userId = Meteor.userId();
if (!userId) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', {
method: 'removeOAuthService',
});
}
if ((await hasPermissionAsync(userId, 'add-oauth-service')) !== true) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'removeOAuthService' });
}
await removeCustomOAuthSettings(name);
},
});
View on GitHub (pinned to b2c16d5842)
Solutions
- Log in with a valid session before calling removeOAuthService
- Migrate to /v1/settings.removeCustomOAuth with an authenticated request
- For scripts, authenticate first via REST
Defensive patterns
Strategy: validation
Validate before calling
if (!Meteor.userId()) {
// re-login before removing a custom OAuth service
}
await Meteor.callAsync('removeOAuthService', name); Try / catch
try {
await Meteor.callAsync('removeOAuthService', name);
} catch (err) {
if (err instanceof Meteor.Error && err.error === 'error-invalid-user') {
// session expired: re-login, then retry
}
} Prevention
- Require an authenticated session for destructive settings operations
- Use /v1/settings.removeCustomOAuth with explicit auth in scripts
When it happens
Trigger: Calling removeOAuthService(name) while logged out or with an expired/invalidated session token.
Common situations: Session dropped while the OAuth settings page was open; scripts calling the method without a login flow.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/bede997d3a39a6f1.
Report an issue: GitHub.