{"record":{"id":"9e58c9b274a79771","repo":"RocketChat/Rocket.Chat","slug":"sla-with-id-id-not-found","errorCode":null,"errorMessage":"SLA with id ${_id} not found","messagePattern":"SLA with id (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/lib/omnichannel/LivechatEnterprise.ts","lineNumber":181,"sourceCode":"\t\tconst sla = await OmnichannelServiceLevelAgreements.createOrUpdatePriority(slaData, _id);\n\t\tif (!oldSLA) {\n\t\t\treturn sla;\n\t\t}\n\n\t\tconst { dueTimeInMinutes: oldDueTimeInMinutes } = oldSLA;\n\t\tconst { dueTimeInMinutes } = sla;\n\n\t\tif (oldDueTimeInMinutes !== dueTimeInMinutes) {\n\t\t\tawait updateSLAInquiries(executedBy, sla);\n\t\t}\n\n\t\treturn sla;\n\t},\n\n\tasync removeSLA(executedBy: string, _id: string) {\n\t\tconst removedResult = await OmnichannelServiceLevelAgreements.removeById(_id);\n\t\tif (!removedResult || removedResult.deletedCount !== 1) {\n\t\t\tthrow new Error(`SLA with id ${_id} not found`);\n\t\t}\n\n\t\tawait removeSLAFromRooms(_id, executedBy);\n\t},\n};\n","sourceCodeStart":163,"sourceCodeEnd":187,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/lib/omnichannel/LivechatEnterprise.ts#L163-L187","documentation":"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.","triggerScenarios":"removeSLA called with an _id that does not exist, was already removed, or (theoretically) where the model removed more than one document (data corruption).","commonSituations":"Retry after a transient failure that already succeeded; stale UI; migration script that deletes the same SLA twice.","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."],"exampleFix":"// before\nawait removeSLA(executedBy, _id);\n\n// after\ntry { await removeSLA(executedBy, _id); }\ncatch (e) {\n  if (e instanceof Error && /not found/.test(e.message)) return;\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"const sla = await OmnichannelServiceLevelAgreements.findOneById(_id, { projection: { _id: 1 } });\nif (!sla) return; // already removed","typeGuard":"const slaExists = async (_id: string) => Boolean(await OmnichannelServiceLevelAgreements.findOneById(_id, { projection: { _id: 1 } }));","tryCatchPattern":"try { await removeSLA(executedBy, _id); }\ncatch (e) {\n  if (e instanceof Error && /not found/.test(e.message)) return;\n  throw e;\n}","preventionTips":["Pre-confirm SLA existence before delete.","Match by substring because no stable code is provided."],"tags":["omnichannel","sla","plain-error","idempotency"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}