{"record":{"id":"9661bc77f1616f1d","repo":"RocketChat/Rocket.Chat","slug":"error-nickname-size-exceeded","errorCode":"error-nickname-size-exceeded","errorMessage":"Nickname size exceeds ${MAX_NICKNAME_LENGTH} characters","messagePattern":"Nickname size exceeds (.+?) characters","errorType":"exception","errorClass":"MeteorError","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/users/saveUser/handleNickname.ts","lineNumber":12,"sourceCode":"import { MeteorError } from '@rocket.chat/core-services';\nimport type { IUser } from '@rocket.chat/core-typings';\nimport type { Updater } from '@rocket.chat/model-typings';\n\nimport type { SaveUserData } from './saveUser';\n\nconst MAX_NICKNAME_LENGTH = 120;\n\nexport const handleNickname = (userUpdater: Updater<IUser>, nickname: SaveUserData['nickname']) => {\n\tif (nickname?.trim()) {\n\t\tif (nickname.length > MAX_NICKNAME_LENGTH) {\n\t\t\tthrow new MeteorError('error-nickname-size-exceeded', `Nickname size exceeds ${MAX_NICKNAME_LENGTH} characters`, {\n\t\t\t\tmethod: 'saveUserProfile',\n\t\t\t});\n\t\t}\n\t\tuserUpdater.set('nickname', nickname);\n\t} else {\n\t\tuserUpdater.unset('nickname');\n\t}\n};\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/users/saveUser/handleNickname.ts#L1-L21","documentation":"saveUserProfile's nickname handler throws error-nickname-size-exceeded (MeteorError, method 'saveUserProfile') when the submitted nickname exceeds 120 characters. Like the bio guard it uses the raw length of a non-blank value; blank nicknames are unset rather than validated.","triggerScenarios":"Profile save with a nickname longer than 120 characters: paste accidents, autocomplete filling display titles, or clients that never cap the field.","commonSituations":"Mobile app or custom frontend without a maxLength on nickname; data migrations importing nickname fields from another system without sanitizing length.","solutions":["Cap the input at maxLength=120 in the form","Validate nickname?.length <= 120 (and trim) before invoking the save","For imported data, truncate nicknames during the import step"],"exampleFix":"// before\nawait saveUserProfile({ nickname }); // 130 chars -> error-nickname-size-exceeded\n\n// after\nconst MAX_NICKNAME_LENGTH = 120;\nconst nickname = rawNickname?.slice(0, MAX_NICKNAME_LENGTH);\nawait saveUserProfile({ nickname });","handlingStrategy":"validation","validationCode":"const MAX_NICKNAME_LENGTH = 120; // must match handleNickname.ts\nif (nickname && nickname.length > MAX_NICKNAME_LENGTH) {\n  throw new Error(`Nickname must be at most ${MAX_NICKNAME_LENGTH} characters`);\n}\nawait saveUserProfile({ nickname });","typeGuard":"const isNicknameWithinLimit = (nickname: string | undefined): boolean => !nickname || nickname.length <= 120;","tryCatchPattern":"try {\n  await saveUserProfile({ nickname });\n} catch (e) {\n  if (isMeteorErrorCode(e, 'error-nickname-size-exceeded')) {\n  \tshowCounterError('nickname', 120);\n  }\n}","preventionTips":["Cap the nickname input at maxLength=120","Truncate imported nicknames at import time"],"tags":["users","profile","nickname","validation","length-limit"],"backgroundTag":"max-length-exceeded","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}