{"record":{"id":"4f0d37620721e002","repo":"RocketChat/Rocket.Chat","slug":"tag-not-found","errorCode":"tag-not-found","errorMessage":"Tag not found","messagePattern":"Tag not found","errorType":"exception","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/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/lib/omnichannel/LivechatEnterprise.ts#L119-L155","documentation":"Thrown by removeTag in LivechatEnterprise.ts:137 when no LivechatTag row matches the supplied _id (findOneById with name projection returns null). The tag is fetched before deletion so the afterTagRemoved callback can receive the full tag object. Meteor.Error 'tag-not-found' with method 'livechat:removeTag'.","triggerScenarios":"Calling livechat:removeTag with an _id that was already deleted, or a malformed/non-existent id. Concurrent deletion between two admins also produces it.","commonSituations":"Stale tag-management UI; double-click on delete; CI test that deletes the same tag twice.","solutions":["Refresh the tag list and confirm the _id is present before deleting.","Treat 'tag-not-found' as an idempotent no-op in the client handler.","Guard the UI delete button against double-submission."],"exampleFix":"// before\nawait removeTag(_id);\n\n// after\ntry { await removeTag(_id); }\ncatch (e) {\n  if (e instanceof Meteor.Error && e.error === 'tag-not-found') return;\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"const tag = await LivechatTag.findOneById(_id, { projection: { _id: 1 } });\nif (!tag) return; // already gone","typeGuard":"const tagExists = async (_id: string) => Boolean(await LivechatTag.findOneById(_id, { projection: { _id: 1 } }));","tryCatchPattern":"try { await removeTag(_id); }\ncatch (e) {\n  if (e instanceof Meteor.Error && e.error === 'tag-not-found') return;\n  throw e;\n}","preventionTips":["Guard the UI delete button against double submission.","Treat removeTag as idempotent on the client."],"tags":["omnichannel","tags","meteor-error"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}