{"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/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/lib/omnichannel/LivechatEnterprise.ts#L163-L187","documentation":"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'.","triggerScenarios":"Calling removeSLA with a stale or wrong SLA id; concurrent deletion of the same SLA.","commonSituations":"UI list out of date after a removal elsewhere; repeated delete clicks; scripts replaying deletion steps.","solutions":["Re-fetch the SLA list and retry with a currently existing id","Treat 'not found' on delete as success if the goal is the SLA being gone","Guard against double-submits in the UI"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const sla = await OmnichannelServiceLevelAgreements.findOneById(_id);\nif (!sla) {\n\t// already removed; nothing to do\n}\nawait LivechatEnterprise.removeSLA(executedBy, _id);","typeGuard":null,"tryCatchPattern":"try {\n\tawait LivechatEnterprise.removeSLA(executedBy, _id);\n} catch (err) {\n\tif (err instanceof Error && /^SLA with id .+ not found$/.test(err.message)) {\n\t\t// treat as success: the SLA is gone\n\t} else {\n\t\tthrow err;\n\t}\n}","preventionTips":["Treat SLA delete as idempotent in automation","Refresh SLA lists before removal after concurrent changes","Guard double-click on delete controls"],"tags":["omnichannel","sla","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}