RocketChat/Rocket.Chat · error · Meteor.Error
Custom_User_Status_Error_Name_Already_In_Use
Custom_User_Status_Error_Name_Already_In_Use
Error message
The custom user status name is already in use
What it means
A custom user status with the same name already exists: the method found a conflicting document via findOneByName (on create) or findOneByNameExceptId (on update, excluding the record being edited). Custom status names must be unique.
Source
Thrown at apps/meteor/server/meteor-methods/users/insertOrUpdateUserStatus.ts:60
// allow all characters except >, <, &, ", '
// more practical than allowing specific sets of characters; also allows foreign languages
const nameValidation = /[><&"']/;
if (nameValidation.test(userStatusData.name)) {
throw new Meteor.Error('error-input-is-not-a-valid-field', `${userStatusData.name} is not a valid name`, {
method: 'insertOrUpdateUserStatus',
input: userStatusData.name,
field: 'Name',
});
}
const conflictingUserStatus = userStatusData._id
? await CustomUserStatus.findOneByNameExceptId(userStatusData.name, userStatusData._id, { projection: { _id: 1 } })
: await CustomUserStatus.findOneByName(userStatusData.name, { projection: { _id: 1 } });
if (conflictingUserStatus) {
throw new Meteor.Error('Custom_User_Status_Error_Name_Already_In_Use', 'The custom user status name is already in use', {
method: 'insertOrUpdateUserStatus',
});
}
const validStatusTypes = ['online', 'away', 'busy', 'offline'];
if (userStatusData.statusType && validStatusTypes.indexOf(userStatusData.statusType) < 0) {
throw new Meteor.Error('error-input-is-not-a-valid-field', `${userStatusData.statusType} is not a valid status type`, {
method: 'insertOrUpdateUserStatus',
input: userStatusData.statusType,
field: 'StatusType',
});
}
if (!userStatusData._id) {
// insert user status
const createUserStatus: InsertionModel<ICustomUserStatus> = {
name: userStatusData.name,
statusType: userStatusData.statusType,View on GitHub (pinned to b2c16d5842)
Solutions
- List existing statuses first (listCustomUserStatus) and pick a unique name before saving
- When updating, exclude the current record's _id from your duplicate check
- Catch this code and surface 'name already in use' next to the input field
Example fix
// before
await Meteor.callAsync('insertOrUpdateUserStatus', { name });
// after — pre-check for duplicates (still keep the catch for races)
const existing = (await Meteor.callAsync('listCustomUserStatus')).some(
(s) => s.name === name && s._id !== editingId,
);
if (existing) {
showInlineError('name already in use');
return;
}
await Meteor.callAsync('insertOrUpdateUserStatus', { name }); Defensive patterns
Strategy: try-catch
Validate before calling
const existing = (await Meteor.callAsync<ICustomUserStatus[]>('listCustomUserStatus'))
.some((s) => s.name === name && s._id !== editingId);
if (existing) {
setFieldError('name', 'Name already in use');
return;
} Try / catch
try {
await Meteor.callAsync('insertOrUpdateUserStatus', data);
} catch (err) {
if (err instanceof Meteor.Error && err.error === 'Custom_User_Status_Error_Name_Already_In_Use') {
// server-authoritative duplicate — prompt for a different name (race with pre-check)
}
} Prevention
- Pre-check names against listCustomUserStatus before save, but keep the catch for races
- When renaming, exclude the edited record's _id from the duplicate check
- Make create-status forms idempotent on retry instead of resubmitting the same name
When it happens
Trigger: Creating a status whose name matches an existing one; renaming a status to a name another status already uses.
Common situations: Two admins creating similar statuses concurrently; renaming into an existing name; re-running an import/setup script that creates the same status twice.
Related errors
- error-invalid-shortcut
- duplicated-account
- error-archived-duplicate-name
- error-duplicate-channel-name
- Custom_User_Status_Error_Invalid_User_Status
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/f1cd46a081037b88.
Report an issue: GitHub.