RocketChat/Rocket.Chat · error · Error
error-duplicated-sla
error-duplicated-sla
Error message
error-duplicated-sla
What it means
Thrown by saveSLA in LivechatEnterprise.ts:160 when OmnichannelServiceLevelAgreements.findDuplicate(_id, name, dueTimeInMinutes) returns truthy, i.e. another SLA already has the same name or dueTimeInMinutes combination. NOTE: this uses `new Error('error-duplicated-sla')`, a plain Error, NOT a Meteor.Error — the code string is the message, so it does not carry a structured error code over the Meteor wire.
Source
Thrown at apps/meteor/ee/server/lib/omnichannel/LivechatEnterprise.ts:160
},
async saveTag(_id: string | undefined, tagData: { name: string; description?: string }, tagDepartments: string[] | undefined) {
return LivechatTag.createOrUpdateTag(_id, tagData, tagDepartments);
},
async saveSLA(
_id: string | null,
slaData: Pick<IOmnichannelServiceLevelAgreements, 'name' | 'description' | 'dueTimeInMinutes'>,
executedBy: string,
) {
const oldSLA =
_id &&
(await OmnichannelServiceLevelAgreements.findOneById<Pick<IOmnichannelServiceLevelAgreements, 'dueTimeInMinutes'>>(_id, {
projection: { dueTimeInMinutes: 1 },
}));
const exists = await OmnichannelServiceLevelAgreements.findDuplicate(_id, slaData.name, slaData.dueTimeInMinutes);
if (exists) {
throw new Error('error-duplicated-sla');
}
const sla = await OmnichannelServiceLevelAgreements.createOrUpdatePriority(slaData, _id);
if (!oldSLA) {
return sla;
}
const { dueTimeInMinutes: oldDueTimeInMinutes } = oldSLA;
const { dueTimeInMinutes } = sla;
if (oldDueTimeInMinutes !== dueTimeInMinutes) {
await updateSLAInquiries(executedBy, sla);
}
return sla;
},
async removeSLA(executedBy: string, _id: string) {View on GitHub (pinned to f9d3ec372b)
Solutions
- Pick a unique name and a dueTimeInMinutes not already used by another SLA.
- Pre-check with the SLA list endpoint before submitting the form.
- Catch by message === 'error-duplicated-sla' (string match, since it is a plain Error).
Example fix
// before
await saveSLA(_id, { name, description, dueTimeInMinutes }, executedBy);
// after
const dup = await OmnichannelServiceLevelAgreements.findDuplicate(_id, name, dueTimeInMinutes);
if (dup) throw new Error('choose a unique SLA name/dueTime');
await saveSLA(_id, { name, description, dueTimeInMinutes }, executedBy); Defensive patterns
Strategy: validation
Validate before calling
const dup = await OmnichannelServiceLevelAgreements.findDuplicate(_id, name, dueTimeInMinutes);
if (dup) throw new Error('SLA name/dueTime already used'); Type guard
const isSlaUnique = async (_id, name, dueTimeInMinutes) => !(await OmnichannelServiceLevelAgreements.findDuplicate(_id, name, dueTimeInMinutes));
Try / catch
try { await saveSLA(_id, slaData, executedBy); }
catch (e) {
if (e instanceof Error && e.message === 'error-duplicated-sla') { /* prompt unique name */ return; }
throw e;
} Prevention
- Pre-check uniqueness before submitting the SLA form.
- Maintain an SLA list cache to validate name client-side.
When it happens
Trigger: Creating a new SLA whose name or dueTimeInMinutes collides with an existing one, or renaming/updating an SLA to a name already taken by a different _id. findDuplicate excludes the current _id, so collisions only flag *other* rows.
Common situations: Admin picks a duplicate SLA name; import/migration script creates SLAs with overlapping due times; UI does not pre-check uniqueness.
Related errors
- SLA with id ${_id} not found
- error-business-hour-name-already-in-use
- error-invalid-inquiry
- error-invalid-sla
- error-invalid-user
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/d6f212fd35838a5d.
Report an issue: GitHub.