RocketChat/Rocket.Chat · error · MeteorError

error-nickname-size-exceeded

error-nickname-size-exceeded

Error message

Nickname size exceeds ${MAX_NICKNAME_LENGTH} characters

What it means

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.

Source

Thrown at apps/meteor/server/lib/users/saveUser/handleNickname.ts:12

import { MeteorError } from '@rocket.chat/core-services';
import type { IUser } from '@rocket.chat/core-typings';
import type { Updater } from '@rocket.chat/model-typings';

import type { SaveUserData } from './saveUser';

const MAX_NICKNAME_LENGTH = 120;

export const handleNickname = (userUpdater: Updater<IUser>, nickname: SaveUserData['nickname']) => {
	if (nickname?.trim()) {
		if (nickname.length > MAX_NICKNAME_LENGTH) {
			throw new MeteorError('error-nickname-size-exceeded', `Nickname size exceeds ${MAX_NICKNAME_LENGTH} characters`, {
				method: 'saveUserProfile',
			});
		}
		userUpdater.set('nickname', nickname);
	} else {
		userUpdater.unset('nickname');
	}
};

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Cap the input at maxLength=120 in the form
  2. Validate nickname?.length <= 120 (and trim) before invoking the save
  3. For imported data, truncate nicknames during the import step

Example fix

// before
await saveUserProfile({ nickname }); // 130 chars -> error-nickname-size-exceeded

// after
const MAX_NICKNAME_LENGTH = 120;
const nickname = rawNickname?.slice(0, MAX_NICKNAME_LENGTH);
await saveUserProfile({ nickname });
Defensive patterns

Strategy: validation

Validate before calling

const MAX_NICKNAME_LENGTH = 120; // must match handleNickname.ts
if (nickname && nickname.length > MAX_NICKNAME_LENGTH) {
  throw new Error(`Nickname must be at most ${MAX_NICKNAME_LENGTH} characters`);
}
await saveUserProfile({ nickname });

Type guard

const isNicknameWithinLimit = (nickname: string | undefined): boolean => !nickname || nickname.length <= 120;

Try / catch

try {
  await saveUserProfile({ nickname });
} catch (e) {
  if (isMeteorErrorCode(e, 'error-nickname-size-exceeded')) {
  	showCounterError('nickname', 120);
  }
}

Prevention

When it happens

Trigger: Profile save with a nickname longer than 120 characters: paste accidents, autocomplete filling display titles, or clients that never cap the field.

Common situations: Mobile app or custom frontend without a maxLength on nickname; data migrations importing nickname fields from another system without sanitizing length.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/9661bc77f1616f1d. Report an issue: GitHub.