RocketChat/Rocket.Chat · error · MeteorError
error-the-field-is-required
error-the-field-is-required
Error message
The field Name is required
What it means
Thrown by validateUserData() on CREATE when the server setting Accounts_RequireNameForSignUp is enabled and the submitted name is empty after trimming. The check only applies to creation (isUpdateUserData false), so updates never need a name even when the setting is on. Code is error-the-field-is-required with field 'Name' in the error details.
Source
Thrown at apps/meteor/server/lib/users/saveUser/validateUserData.ts:57
if (userData.roles) {
const newRoles = userData.roles.filter((roleId) => !existingRoles.includes(roleId));
if (newRoles.length > 0) {
throw new MeteorError('error-action-not-allowed', 'The field Roles consist invalid role id', {
method: 'insertOrUpdateUser',
action: 'Assign_role',
});
}
}
if (userData.roles?.includes('admin') && !(await hasPermissionAsync(userId, 'assign-admin-role'))) {
throw new MeteorError('error-action-not-allowed', 'Assigning admin is not allowed', {
method: 'insertOrUpdateUser',
action: 'Assign_admin',
});
}
if (settings.get('Accounts_RequireNameForSignUp') && !isUpdateUserData(userData) && !trim(userData.name)) {
throw new MeteorError('error-the-field-is-required', 'The field Name is required', {
method: 'insertOrUpdateUser',
field: 'Name',
});
}
if (!isUpdateUserData(userData) && !trim(userData.username)) {
throw new MeteorError('error-the-field-is-required', 'The field Username is required', {
method: 'insertOrUpdateUser',
field: 'Username',
});
}
let nameValidation;
try {
nameValidation = new RegExp(`^${settings.get('UTF8_User_Names_Validation')}$`);
} catch (e) {
nameValidation = new RegExp('^[0-9a-zA-Z-_.]+$');View on GitHub (pinned to b2c16d5842)
Solutions
- Include a non-blank name in the create payload (trim(name) must be non-empty).
- If nameless users are acceptable, disable Accounts_RequireNameForSignUp in Administration -> Accounts -> Registration.
- For provisioning pipelines, default name to the username or email local-part when no display name is available.
Example fix
// before
await POST '/api/v1/users.create', { username: 'alice', email: 'a@b.c', password: 'pw' }); // throws when setting on
// after
await POST '/api/v1/users.create', { username: 'alice', email: 'a@b.c', password: 'pw', name: 'Alice' }); Defensive patterns
Strategy: validation
Validate before calling
const requireName = settings.get('Accounts_RequireNameForSignUp'); // or read public settings via GET /api/v1/settings.public
if (requireName && !payload.name?.trim()) {
throw new Error('Name is required on this workspace');
} Type guard
const hasNonEmptyName = (p: { name?: string }) => !!p.name && p.name.trim().length > 0; Try / catch
catch (e) {
if (e.error === 'error-the-field-is-required' && e.details?.field === 'Name') {
// prompt the user for a display name and resubmit
}
} Prevention
- Make the name input required client-side when the workspace setting is on.
- Default name to username or email local-part in provisioning scripts.
- Re-check workspace settings after admin configuration changes.
When it happens
Trigger: POST /api/v1/users.create with name missing, empty string, or whitespace-only while the workspace requires names; automated provisioning that only supplies username/email/password; a mobile client whose optional name field was left blank.
Common situations: Workspace admin enabled 'Accounts_RequireNameForSignUp' after scripts were written; LDAP/SSO provisioning code that never populated name; UI forms that submit the field as '' instead of omitting it.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- error-input-is-not-a-valid-field
- error-invalid-department
- error-user-param-not-provided
- error-invalid-custom-field-value
- error-invalid-email
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/d5e1a38bb64c1cc4.
Report an issue: GitHub.