RocketChat/Rocket.Chat · error · Meteor.Error

error-could-not-change-name

error-could-not-change-name

Error message

Could not change name

What it means

Thrown when the setRealName library function (server/lib/users/setRealName.ts) returns falsy. It returns undefined when the target user record is missing OR when Accounts_RequireNameForSignUp is true and the trimmed new name is empty - i.e. attempting to clear a name on a workspace that requires names.

Source

Thrown at apps/meteor/server/meteor-methods/users/setRealName.ts:31

		setRealName(name: string): string;
	}
}

Meteor.methods<ServerMethods>({
	async setRealName(name) {
		methodDeprecationLogger.method('setRealName', '9.0.0', '/v1/users.updateOwnBasicInfo');
		check(name, String);
		const userId = Meteor.userId();
		if (!userId) {
			throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'setRealName' });
		}

		if (!settings.get('Accounts_AllowRealNameChange')) {
			throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'setRealName' });
		}

		if (!(await setRealName(userId, name))) {
			throw new Meteor.Error('error-could-not-change-name', 'Could not change name', {
				method: 'setRealName',
			});
		}

		return name;
	},
});

RateLimiter.limitMethod('setRealName', 1, 1000, {
	userId: () => true,
});

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Send a non-empty trimmed name, or skip the call entirely, when the name field is blank on a name-required workspace
  2. Verify Accounts_RequireNameForSignUp state before allowing 'clear name' UX
  3. If clearing names is a legitimate feature, ask the admin to disable Accounts_RequireNameForSignUp

Example fix

// before
Meteor.call('setRealName', nameField.value); // may be ''

// after
const name = nameField.value.trim();
if (name) Meteor.call('setRealName', name);
Defensive patterns

Strategy: validation

Validate before calling

const trimmed = typeof name === 'string' ? name.trim() : '';
if (requireNameForSignUp && !trimmed) {
  showFieldError('name', 'Name is required on this server');
  return; // do not call setRealName
}
if (trimmed) Meteor.call('setRealName', trimmed);

Type guard

const isNonEmptyTrimmedString = (v: unknown): v is string => typeof v === 'string' && v.trim().length > 0;

Try / catch

catch (err) {
  if (err instanceof Meteor.Error && err.error === 'error-could-not-change-name') {
    showFieldError('name', 'Could not save name - check it is not empty');
  }
}

Prevention

When it happens

Trigger: setRealName called with '' or whitespace-only name while Accounts_RequireNameForSignUp=true; or the userId's document no longer exists in the users collection.

Common situations: Profile forms with an optional name field that submit empty strings instead of omitting the field; name-required workspaces; races where the account is deleted mid-submit.

Related errors


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