RocketChat/Rocket.Chat · error · Error

SLA with id not found

Error message

SLA with id ${_id} not found

What it means

removeSLA deletes by id via OmnichannelServiceLevelAgreements.removeById and requires exactly one deleted document. If nothing was deleted (unknown id, already removed), it throws 'SLA with id ${_id} not found'.

Solutions

  1. Re-fetch the SLA list and retry with a currently existing id
  2. Treat 'not found' on delete as success if the goal is the SLA being gone
  3. Guard against double-submits in the UI
Defensive patterns

Strategy: try-catch

Validate before calling

const sla = await OmnichannelServiceLevelAgreements.findOneById(_id);
if (!sla) {
	// already removed; nothing to do
}
await LivechatEnterprise.removeSLA(executedBy, _id);

Try / catch

try {
	await LivechatEnterprise.removeSLA(executedBy, _id);
} catch (err) {
	if (err instanceof Error && /^SLA with id .+ not found$/.test(err.message)) {
		// treat as success: the SLA is gone
	} else {
		throw err;
	}
}

Prevention

When it happens

Trigger: Calling removeSLA with a stale or wrong SLA id; concurrent deletion of the same SLA.

Common situations: UI list out of date after a removal elsewhere; repeated delete clicks; scripts replaying deletion steps.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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

Appendix: source

Thrown at apps/meteor/ee/server/lib/omnichannel/LivechatEnterprise.ts:181

		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) {
		const removedResult = await OmnichannelServiceLevelAgreements.removeById(_id);
		if (!removedResult || removedResult.deletedCount !== 1) {
			throw new Error(`SLA with id ${_id} not found`);
		}

		await removeSLAFromRooms(_id, executedBy);
	},
};

View on GitHub (pinned to b2c16d5842)