{"record":{"id":"daf9e642d31974f4","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-name-daf9e6","errorCode":"error-invalid-name","errorMessage":"Invalid OAuth service name","messagePattern":"Invalid OAuth service name","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/auth/removeOAuthService.ts","lineNumber":22,"sourceCode":"import { check } from 'meteor/check';\nimport { Meteor } from 'meteor/meteor';\n\nimport { hasPermissionAsync } from '../../lib/authorization/hasPermission';\nimport { methodDeprecationLogger } from '../../lib/deprecationWarningLogger';\nimport { notifyOnSettingChangedById } from '../../lib/notifyListener';\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\tremoveOAuthService(name: string): Promise<void>;\n\t}\n}\n\nexport const removeCustomOAuthSettings = async (name: string): Promise<void> => {\n\tconst normalized = capitalize(name.toLowerCase().replace(/[^a-z0-9_]/g, ''));\n\n\tif (!normalized) {\n\t\tthrow new Meteor.Error('error-invalid-name', 'Invalid OAuth service name', { method: 'removeOAuthService' });\n\t}\n\n\tconst settingsIds = [\n\t\t`Accounts_OAuth_Custom-${normalized}`,\n\t\t`Accounts_OAuth_Custom-${normalized}-url`,\n\t\t`Accounts_OAuth_Custom-${normalized}-token_path`,\n\t\t`Accounts_OAuth_Custom-${normalized}-identity_path`,\n\t\t`Accounts_OAuth_Custom-${normalized}-authorize_path`,\n\t\t`Accounts_OAuth_Custom-${normalized}-scope`,\n\t\t`Accounts_OAuth_Custom-${normalized}-access_token_param`,\n\t\t`Accounts_OAuth_Custom-${normalized}-token_sent_via`,\n\t\t`Accounts_OAuth_Custom-${normalized}-identity_token_sent_via`,\n\t\t`Accounts_OAuth_Custom-${normalized}-id`,\n\t\t`Accounts_OAuth_Custom-${normalized}-secret`,\n\t\t`Accounts_OAuth_Custom-${normalized}-button_label_text`,\n\t\t`Accounts_OAuth_Custom-${normalized}-button_label_color`,\n\t\t`Accounts_OAuth_Custom-${normalized}-button_color`,\n\t\t`Accounts_OAuth_Custom-${normalized}-login_style`,","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/auth/removeOAuthService.ts#L4-L40","documentation":"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.","triggerScenarios":"Calling removeOAuthService with an empty string, a whitespace/symbol-only value like '!!!' or '---', or a non-ASCII label that strips to nothing.","commonSituations":"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.","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"],"exampleFix":"// before\nawait Meteor.callAsync('removeOAuthService', '!!!');\n\n// after — mirror the server normalization first\nconst normalized = name.toLowerCase().replace(/[^a-z0-9_]/g, '');\nif (!normalized) throw new Error('Invalid OAuth service name');\nawait Meteor.callAsync('removeOAuthService', name);","handlingStrategy":"validation","validationCode":"// mirror the server-side normalization before calling\nconst normalized = name.toLowerCase().replace(/[^a-z0-9_]/g, '');\nif (!normalized) {\n  throw new Error('Invalid OAuth service name');\n}\nawait Meteor.callAsync('removeOAuthService', name);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('removeOAuthService', name);\n} catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'error-invalid-name') {\n    // ask for the exact service name from Accounts_OAuth_Custom-* ids\n  }\n}","preventionTips":["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"],"tags":["oauth","validation","settings","meteor-methods"],"backgroundTag":"invalid-identifier","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}