RocketChat/Rocket.Chat · error · Error
error-duplicate-priority-name
error-duplicate-priority-name
Error message
error-duplicate-priority-name
What it means
Thrown by updatePriority (reached via PUT livechat/priorities/:priorityId) when the requested name already belongs to a different LivechatPriority. The check uses LivechatPriority.findOneNameUsingRegex, so the match is regex-based and effectively case-insensitive; a name whose regex metacharacters match another priority can also trip it. The source comment notes translated duplicates are deliberately not enforced. The MongoDB update never runs when this fires.
Solutions
- Choose a name no other priority uses, accounting for case-insensitive matching (list them with GET /api/v1/livechat/priorities first).
- If swapping names, rename the existing priority to a temporary name before assigning its name to the target.
- If the duplicate report looks false, remove regex metacharacters such as . * + ? [ ] ( ) | from the name and retry, since the lookup is regex-based.
- Send {"reset": true} instead of a name if you only want to restore that priority's default name.
Example fix
// before
await api.put(`/v1/livechat/priorities/${priorityId}`, { name: 'high' });
// -> error-duplicate-priority-name: a priority named "High" already exists
// after
const { priorities } = await api.get('/v1/livechat/priorities', { params: { count: 0 } });
const taken = priorities.some((p) => p._id !== priorityId && p.name.toLowerCase() === 'high');
await api.put(`/v1/livechat/priorities/${priorityId}`, { name: taken ? 'High - Tier 2' : 'high' }); Defensive patterns
Strategy: validation
Validate before calling
const { priorities } = await api.get('/v1/livechat/priorities', { params: { count: 0 } });
const conflict = priorities.some(
(p) => p._id !== priorityId && p.name.toLowerCase() === newName.toLowerCase(),
);
if (conflict) throw new Error(`Priority name "${newName}" is already in use`);
await api.put(`/v1/livechat/priorities/${priorityId}`, { name: newName }); Try / catch
try {
await api.put(`/v1/livechat/priorities/${priorityId}`, { name });
} catch (e) {
if (e?.response?.data?.errorType === 'error-duplicate-priority-name') {
// prompt the user for another name; do NOT retry with the same value
} else throw e;
} Prevention
- Treat priority names as unique case-insensitive keys; check the list endpoint before every rename.
- Keep regex metacharacters out of priority names.
- When swapping two names, rename via a temporary name first.
When it happens
Trigger: PUT /api/v1/livechat/priorities/:priorityId with body {"name": "high"} while another priority is already named "High"; or a name containing regex metacharacters (e.g. "Hi.g", "Urgent*") whose pattern matches an existing priority name. Also fires when renaming priority A to B's name without renaming B first.
Common situations: Renaming priorities to canonical names (High/Urgent) that already exist; API seeding scripts where only casing differs; names pasted from chat that contain dots, asterisks, or brackets; swapping two priority names in the wrong order.
Related errors
- error-invalid-priority
- agent-not-found
- error-forwarding-chat
- error-invalid-department-unit
- error-invalid-params
AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18).
Data as JSON: /api/errors/7230480182c3a851.
Report an issue: GitHub.
Appendix: source
Thrown at apps/meteor/ee/server/api/v1/omnichannel/lib/priorities.ts:49
limit: count,
});
const [priorities, total] = await Promise.all([cursor.toArray(), totalCount]);
return {
priorities,
count: priorities.length,
offset,
total,
};
}
export async function updatePriority(_id: string, data: Pick<ILivechatPriority, 'name'> & { reset?: boolean }): Promise<ILivechatPriority> {
if (data.name) {
// If we want to enforce translated duplicates we need to change this
const priority = await LivechatPriority.findOneNameUsingRegex(data.name, { projection: { name: 1 } });
if (priority && priority._id !== _id) {
throw new Error('error-duplicate-priority-name');
}
}
const createdResult = await LivechatPriority.updatePriority(_id, data.reset || false, data.name);
if (!createdResult) {
logger.error({ msg: 'Error updating priority: unsuccessful result from MongoDB', priorityId: _id, result: createdResult });
throw Error('error-unable-to-update-priority');
}
return createdResult;
}
export const updateRoomPriority = async (
rid: string,
user: Required<Pick<IUser, '_id' | 'username' | 'name'>>,
priorityId: string,
): Promise<void> => {View on GitHub (pinned to b2c16d5842)