RocketChat/Rocket.Chat · error · Meteor.Error
error-user-registration-custom-field
error-user-registration-custom-field
Error message
Field ${fieldName} is required What it means
The Accounts_CustomFields definition marks a field required: true, and the submitted fields object carries an empty or whitespace-only value for it (trimmed with trim() before the check). Thrown per field inside the loop at validateCustomFields.js:27-30 with the offending fieldName in the message and { method: 'registerUser' } in details.
Source
Thrown at apps/meteor/server/lib/users/validateCustomFields.js:29
}
let customFieldsMeta;
try {
customFieldsMeta = JSON.parse(settings.get('Accounts_CustomFields'));
} catch (e) {
throw new Meteor.Error('error-invalid-customfield-json', 'Invalid JSON for Custom Fields');
}
const customFields = {};
Object.keys(customFieldsMeta).forEach((fieldName) => {
const field = customFieldsMeta[fieldName];
customFields[fieldName] = fields[fieldName];
const fieldValue = trim(fields[fieldName]);
if (field.required && fieldValue === '') {
throw new Meteor.Error('error-user-registration-custom-field', `Field ${fieldName} is required`, { method: 'registerUser' });
}
if (field.type === 'select' && field.options.indexOf(fields[fieldName]) === -1) {
throw new Meteor.Error('error-user-registration-custom-field', `Value for field ${fieldName} is invalid`, { method: 'registerUser' });
}
if (field.maxLength && fieldValue.length > field.maxLength) {
throw new Meteor.Error('error-user-registration-custom-field', `Max length of field ${fieldName} ${field.maxLength}`, {
method: 'registerUser',
});
}
if (field.minLength && fieldValue.length > 0 && fieldValue.length < field.minLength) {
throw new Meteor.Error('error-user-registration-custom-field', `Min length of field ${fieldName} ${field.minLength}`, {
method: 'registerUser',
});
}
});View on GitHub (pinned to b2c16d5842)
Solutions
- Submit a non-empty value for the field named in the error message
- Mark the input required in the client form so validation blocks submit early
- If the field should be optional, remove required (or set required: false) in Accounts_CustomFields
Example fix
// before
validateCustomFields({ department: '' }); // Field department is required
// after
validateCustomFields({ department: 'sales' }); Defensive patterns
Strategy: validation
Validate before calling
const meta = JSON.parse(settings.get('Accounts_CustomFields'));
const missing = Object.entries(meta)
.filter(([key, field]) => field.required && String(fields[key] ?? '').trim() === '')
.map(([key]) => key);
if (missing.length) {
// block submit and highlight these inputs
} Try / catch
try {
validateCustomFields(fields);
} catch (error) {
if (error instanceof Meteor.Error && error.error === 'error-user-registration-custom-field' && /required/i.test(error.reason)) {
// flag the field named in the message
} else {
throw error;
}
} Prevention
- Mirror required flags into the form schema when the setting changes
- Trim client-side before submit — whitespace does not satisfy required
- Re-sync the client form definition whenever Accounts_CustomFields changes
When it happens
Trigger: Registering or saving a profile that omits a required custom field, submits an empty string, or submits only whitespace for it.
Common situations: Client forms that don't mark the custom input as required; fields made mandatory by the admin after the form/UI was built; API registrations written before the field existed.
Related errors
- duplicated-account
- error-invalid-account
- error-invalid-custom-field-value
- error-custom-field-not-allowed
- error-invalid-custom-field-value
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/ff61027cee8d028b.
Report an issue: GitHub.