{"record":{"id":"801a6ef8486b89c2","repo":"RocketChat/Rocket.Chat","slug":"error-blocked-username","errorCode":"error-blocked-username","errorMessage":"`${_.escape(username)} is blocked and can't be used!`","messagePattern":"`(.+?) is blocked and can't be used!`","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/users/checkUsernameAvailability.ts","lineNumber":46,"sourceCode":"\tconst user = await Users.findOneById(userId, { projection: { username: 1 } });\n\n\tif (!user) {\n\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'setUsername' });\n\t}\n\n\tif (user.username && !settings.get('Accounts_AllowUsernameChange')) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'setUsername' });\n\t}\n\n\tif (user.username === username) {\n\t\treturn true;\n\t}\n\treturn checkUsernameAvailability(username);\n};\n\nexport const checkUsernameAvailability = async function (username: string, type: UsernameAvailabilityCheckType = 'user'): Promise<boolean> {\n\tif (usernameIsBlocked(username, usernameBlackList) || !validateName(username)) {\n\t\tthrow new Meteor.Error('error-blocked-username', `${_.escape(username)} is blocked and can't be used!`, {\n\t\t\tmethod: 'checkUsernameAvailability',\n\t\t\tfield: username,\n\t\t});\n\t}\n\n\t// Make sure no users are using this username\n\tconst existingUser = await Users.findOneByUsernameIgnoringCase(username, {\n\t\tprojection: { _id: 1 },\n\t});\n\tif (existingUser) {\n\t\treturn false;\n\t}\n\n\t// Make sure no teams are using this username\n\tconst existingTeam = await Team.getOneByName(toRegExp(username), { projection: { _id: 1 } });\n\tif (existingTeam) {\n\t\treturn false;\n\t}","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/users/checkUsernameAvailability.ts#L28-L64","documentation":"checkUsernameAvailability throws error-blocked-username (method 'checkUsernameAvailability', field = the attempted username) when the name is reserved or malformed: usernameIsBlocked matches the blacklist built from ['all', 'here'] plus Accounts_BlockedUsernameList, or validateName rejects the format. Note the same error covers both cases, so the message 'is blocked and can't be used' can also mean 'fails the username format rules'.","triggerScenarios":"Choosing 'all', 'here', or any entry listed in Accounts_BlockedUsernameList; using characters that fail validateName (emoji, symbols, invalid UTF-8 sequences, leading/trailing punctuation); brand names an admin reserved via the blacklist setting.","commonSituations":"Registration or username-change form accepting anything client-side; admins adding reserved words (admin, support, root) to the blocked list later, breaking existing signup flows that suggest such names; usernames imported from another system with exotic characters.","solutions":["Pick a different username: anything matching the blocked list or the format rules will always fail","Check the Admin > Settings > Accounts > Blocked Username List for entries that accidentally match legitimate names (entries are comma-separated and matched case-insensitively as full-string regexes)","Run the same checks client-side before submitting: validateName(username) plus your own copy of the blocked list"],"exampleFix":"// before\nMeteor.call('setUsername', username); // 'all' -> error-blocked-username\n\n// after\nconst RESERVED = [/^all$/i, /^here$/i];\nconst isValidFormat = /^[a-zA-Z0-9._-]+$/.test(username); // mirror your username policy\nif (!username || RESERVED.some((r) => r.test(username)) || !isValidFormat) {\n  showFieldError('This username is reserved or invalid');\n} else {\n  Meteor.call('setUsername', username);\n}","handlingStrategy":"validation","validationCode":"const RESERVED = [/^all$/i, /^here$/i];\nconst passesFormat = /^[a-zA-Z0-9._-]+$/.test(username);\nif (!username || RESERVED.some((r) => r.test(username)) || !passesFormat) {\n  throw new Error('Username is reserved or invalid');\n}\nreturn checkUsernameAvailability(username);","typeGuard":"const isBlockedUsernameError = (e: unknown): boolean =>\n  typeof e === 'object' && e !== null && (e as { error?: unknown }).error === 'error-blocked-username';","tryCatchPattern":"try {\n  await checkUsernameAvailability(username);\n} catch (e) {\n  if (isBlockedUsernameError(e)) {\n  \tsuggestAlternative(username); // error covers BOTH reserved words and format failures\n  }\n}","preventionTips":["Mirror the blocked list client-side, but keep the server as the source of truth","Show a live availability indicator during signup instead of failing on submit","When editing Accounts_BlockedUsernameList remember entries are full-string, case-insensitive matches"],"tags":["users","username","validation","reserved-words","settings"],"backgroundTag":"reserved-username","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}