RocketChat/Rocket.Chat · error · Error

error-duplicated-sla

Error message

error-duplicated-sla

What it means

saveSLA checks OmnichannelServiceLevelAgreements.findDuplicate(_id, name, dueTimeInMinutes) before writing. If another SLA already occupies the same name, it throws error-duplicated-sla to keep SLA names unique.

Solutions

  1. List existing SLAs and pick a unique name
  2. Delete or rename the conflicting SLA first, then save
  3. For imports, de-duplicate by name before applying
Defensive patterns

Strategy: try-catch

Validate before calling

const duplicate = await OmnichannelServiceLevelAgreements.findDuplicate(_id, slaData.name, slaData.dueTimeInMinutes);
if (duplicate) {
	// pick a different name before saving
}
await LivechatEnterprise.saveSLA(_id, slaData, executedBy);

Try / catch

try {
	await LivechatEnterprise.saveSLA(_id, slaData, executedBy);
} catch (err) {
	if (err instanceof Error && err.message === 'error-duplicated-sla') {
		// show 'an SLA with this name already exists' and keep the form open
	} else {
		throw err;
	}
}

Prevention

When it happens

Trigger: Creating an SLA with a name already in use, or editing an SLA's name to collide with another existing SLA.

Common situations: Two admins creating similarly named SLAs; re-importing a configuration that already exists; renaming to a name thought to be free.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/d6f212fd35838a5d. Report an issue: GitHub.

Appendix: 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 b2c16d5842)