RocketChat/Rocket.Chat · error · Error
SLA with id ${_id} not found
Error message
SLA with id ${_id} not found What it means
Thrown by removeSLA in LivechatEnterprise.ts:181 when removeById returns falsy or a result whose deletedCount is not exactly 1. The strict deletedCount !== 1 check means a partial/multi delete is also treated as failure. NOTE: plain `new Error(...)` with an interpolated message and NO stable error code — callers cannot match by code, only by substring.
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 f9d3ec372b)
Solutions
- Confirm the SLA _id still exists before calling removeSLA.
- Treat 'SLA with id ... not found' as idempotent success in the caller.
- If you maintain this code, consider upgrading to a MeteorError with a stable code for reliable client matching.
Example fix
// before
await removeSLA(executedBy, _id);
// after
try { await removeSLA(executedBy, _id); }
catch (e) {
if (e instanceof Error && /not found/.test(e.message)) return;
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
const sla = await OmnichannelServiceLevelAgreements.findOneById(_id, { projection: { _id: 1 } });
if (!sla) return; // already removed Type guard
const slaExists = async (_id: string) => Boolean(await OmnichannelServiceLevelAgreements.findOneById(_id, { projection: { _id: 1 } })); Try / catch
try { await removeSLA(executedBy, _id); }
catch (e) {
if (e instanceof Error && /not found/.test(e.message)) return;
throw e;
} Prevention
- Pre-confirm SLA existence before delete.
- Match by substring because no stable code is provided.
When it happens
Trigger: removeSLA called with an _id that does not exist, was already removed, or (theoretically) where the model removed more than one document (data corruption).
Common situations: Retry after a transient failure that already succeeded; stale UI; migration script that deletes the same SLA twice.
Related errors
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/9e58c9b274a79771.
Report an issue: GitHub.