RocketChat/Rocket.Chat · error · Meteor.Error
error-invalid-name
error-invalid-name
Error message
Invalid OAuth service name
What it means
removeCustomOAuthSettings normalizes the service name by lowercasing it and stripping every character outside [a-z0-9_]; if nothing remains (empty input, or a name consisting only of spaces, dashes, or symbols) it throws 'error-invalid-name'. The normalized name must be non-empty because it is used to build the Accounts_OAuth_Custom-* setting ids that get removed.
Source
Thrown at apps/meteor/server/meteor-methods/auth/removeOAuthService.ts:22
import { check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import { hasPermissionAsync } from '../../lib/authorization/hasPermission';
import { methodDeprecationLogger } from '../../lib/deprecationWarningLogger';
import { notifyOnSettingChangedById } from '../../lib/notifyListener';
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
removeOAuthService(name: string): Promise<void>;
}
}
export const removeCustomOAuthSettings = async (name: string): Promise<void> => {
const normalized = capitalize(name.toLowerCase().replace(/[^a-z0-9_]/g, ''));
if (!normalized) {
throw new Meteor.Error('error-invalid-name', 'Invalid OAuth service name', { method: 'removeOAuthService' });
}
const settingsIds = [
`Accounts_OAuth_Custom-${normalized}`,
`Accounts_OAuth_Custom-${normalized}-url`,
`Accounts_OAuth_Custom-${normalized}-token_path`,
`Accounts_OAuth_Custom-${normalized}-identity_path`,
`Accounts_OAuth_Custom-${normalized}-authorize_path`,
`Accounts_OAuth_Custom-${normalized}-scope`,
`Accounts_OAuth_Custom-${normalized}-access_token_param`,
`Accounts_OAuth_Custom-${normalized}-token_sent_via`,
`Accounts_OAuth_Custom-${normalized}-identity_token_sent_via`,
`Accounts_OAuth_Custom-${normalized}-id`,
`Accounts_OAuth_Custom-${normalized}-secret`,
`Accounts_OAuth_Custom-${normalized}-button_label_text`,
`Accounts_OAuth_Custom-${normalized}-button_label_color`,
`Accounts_OAuth_Custom-${normalized}-button_color`,
`Accounts_OAuth_Custom-${normalized}-login_style`,View on GitHub (pinned to b2c16d5842)
Solutions
- Pass the custom OAuth service name exactly as configured (letters, digits, underscores), e.g. 'my-custom-sso'
- Check the Accounts_OAuth_Custom-* ids in the admin OAuth settings to see the exact normalized name to pass
- Sanitize client-side with the same rule: name.toLowerCase().replace(/[^a-z0-9_]/g, '') must be non-empty before calling
Example fix
// before
await Meteor.callAsync('removeOAuthService', '!!!');
// after — mirror the server normalization first
const normalized = name.toLowerCase().replace(/[^a-z0-9_]/g, '');
if (!normalized) throw new Error('Invalid OAuth service name');
await Meteor.callAsync('removeOAuthService', name); Defensive patterns
Strategy: validation
Validate before calling
// mirror the server-side normalization before calling
const normalized = name.toLowerCase().replace(/[^a-z0-9_]/g, '');
if (!normalized) {
throw new Error('Invalid OAuth service name');
}
await Meteor.callAsync('removeOAuthService', name); Try / catch
try {
await Meteor.callAsync('removeOAuthService', name);
} catch (err) {
if (err instanceof Meteor.Error && err.error === 'error-invalid-name') {
// ask for the exact service name from Accounts_OAuth_Custom-* ids
}
} Prevention
- Offer a picker of existing custom OAuth service names instead of free-text input
- Restrict names to [a-z0-9_] at creation time so removal can never hit this
- Pass the service name, never an app _id or client id
When it happens
Trigger: Calling removeOAuthService with an empty string, a whitespace/symbol-only value like '!!!' or '---', or a non-ASCII label that strips to nothing.
Common situations: Passing an OAuth app _id or client id instead of the service name; passing a display label made only of stripped characters; copy/paste of invisible characters.
Related errors
- error-name-param-not-provided
- error-invalid-user
- error-invalid-user
- error-invalid-settings
- error-shield-disabled
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/daf9e642d31974f4.
Report an issue: GitHub.