{"record":{"id":"d6f212fd35838a5d","repo":"RocketChat/Rocket.Chat","slug":"error-duplicated-sla","errorCode":null,"errorMessage":"error-duplicated-sla","messagePattern":"error-duplicated-sla","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/lib/omnichannel/LivechatEnterprise.ts","lineNumber":160,"sourceCode":"\t},\n\n\tasync saveTag(_id: string | undefined, tagData: { name: string; description?: string }, tagDepartments: string[] | undefined) {\n\t\treturn LivechatTag.createOrUpdateTag(_id, tagData, tagDepartments);\n\t},\n\n\tasync saveSLA(\n\t\t_id: string | null,\n\t\tslaData: Pick<IOmnichannelServiceLevelAgreements, 'name' | 'description' | 'dueTimeInMinutes'>,\n\t\texecutedBy: string,\n\t) {\n\t\tconst oldSLA =\n\t\t\t_id &&\n\t\t\t(await OmnichannelServiceLevelAgreements.findOneById<Pick<IOmnichannelServiceLevelAgreements, 'dueTimeInMinutes'>>(_id, {\n\t\t\t\tprojection: { dueTimeInMinutes: 1 },\n\t\t\t}));\n\t\tconst exists = await OmnichannelServiceLevelAgreements.findDuplicate(_id, slaData.name, slaData.dueTimeInMinutes);\n\t\tif (exists) {\n\t\t\tthrow new Error('error-duplicated-sla');\n\t\t}\n\n\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) {","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/lib/omnichannel/LivechatEnterprise.ts#L142-L178","documentation":"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.","triggerScenarios":"Creating an SLA with a name already in use, or editing an SLA's name to collide with another existing SLA.","commonSituations":"Two admins creating similarly named SLAs; re-importing a configuration that already exists; renaming to a name thought to be free.","solutions":["List existing SLAs and pick a unique name","Delete or rename the conflicting SLA first, then save","For imports, de-duplicate by name before applying"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const duplicate = await OmnichannelServiceLevelAgreements.findDuplicate(_id, slaData.name, slaData.dueTimeInMinutes);\nif (duplicate) {\n\t// pick a different name before saving\n}\nawait LivechatEnterprise.saveSLA(_id, slaData, executedBy);","typeGuard":null,"tryCatchPattern":"try {\n\tawait LivechatEnterprise.saveSLA(_id, slaData, executedBy);\n} catch (err) {\n\tif (err instanceof Error && err.message === 'error-duplicated-sla') {\n\t\t// show 'an SLA with this name already exists' and keep the form open\n\t} else {\n\t\tthrow err;\n\t}\n}","preventionTips":["Check name uniqueness in the form before submit","De-duplicate by name when importing SLA configurations","Prevent double-submits that can race two saves with the same name"],"tags":["omnichannel","sla","duplicate","validation"],"backgroundTag":"duplicate-record","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"}