{"record":{"id":"4f0d37620721e002","repo":"RocketChat/Rocket.Chat","slug":"tag-not-found","errorCode":"tag-not-found","errorMessage":"Tag not found","messagePattern":"Tag not found","errorType":"error_code","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/lib/omnichannel/LivechatEnterprise.ts","lineNumber":137,"sourceCode":"\t\tconst validUserMonitors = await Users.findUsersInRolesWithQuery(\n\t\t\t'livechat-monitor',\n\t\t\t{ _id: { $in: unitMonitors.map(({ monitorId }) => monitorId) } },\n\t\t\t{ projection: { _id: 1, username: 1 } },\n\t\t).toArray();\n\n\t\tconst monitors = validUserMonitors.map(({ _id: monitorId, username }) => ({\n\t\t\tmonitorId,\n\t\t\tusername: username!,\n\t\t}));\n\n\t\treturn LivechatUnit.createOrUpdateUnit(_id, unitData, ancestors, monitors, unitDepartments);\n\t},\n\n\tasync removeTag(_id: string) {\n\t\tconst tag = await LivechatTag.findOneById<Pick<ILivechatTag, '_id' | 'name'>>(_id, { projection: { _id: 1, name: 1 } });\n\n\t\tif (!tag) {\n\t\t\tthrow new Meteor.Error('tag-not-found', 'Tag not found', { method: 'livechat:removeTag' });\n\t\t}\n\n\t\tawait callbacks.run('livechat.afterTagRemoved', tag);\n\t\treturn LivechatTag.removeById(_id);\n\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, {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/ee/server/lib/omnichannel/LivechatEnterprise.ts#L119-L155","documentation":"removeTag loads the livechat tag by id before deleting and running the livechat.afterTagRemoved callback. If no tag matches the id, it throws tag-not-found for method livechat:removeTag.","triggerScenarios":"Calling livechat:removeTag with a deleted or never-existing tag id; double-delete from concurrent UI actions.","commonSituations":"Two admins deleting the same tag; stale tag list after removal; automation re-running a delete step.","solutions":["Refresh the tags list and only delete ids that still appear","Make delete flows idempotent: treat tag-not-found as success when the goal is absence","Verify the id via the tag list endpoint before deleting"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const tag = await LivechatTag.findOneById(_id, { projection: { _id: 1 } });\nif (!tag) {\n\t// already removed; nothing to do\n}\nawait LivechatEnterprise.removeTag(_id);","typeGuard":null,"tryCatchPattern":"try {\n\tawait LivechatEnterprise.removeTag(_id);\n} catch (err) {\n\tif ((err as Meteor.Error)?.error === 'tag-not-found') {\n\t\t// treat as success: the tag is gone\n\t} else {\n\t\tthrow err;\n\t}\n}","preventionTips":["Make tag deletion idempotent in UI and scripts","Refresh the tag list after concurrent edits","Disable the delete button while a deletion is in flight"],"tags":["omnichannel","tag","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"}