{"record":{"id":"74a2a0777c3c2be0","repo":"eyaltoledano/claude-task-master","slug":"tag-tag-not-found","errorCode":null,"errorMessage":"Tag ${tag} not found","messagePattern":"Tag (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts","lineNumber":730,"sourceCode":"\t\t\tlet shouldDeleteFile = false;\n\n\t\t\tawait this.fileOps.modifyJson(filePath, (data: any) => {\n\t\t\t\tif (\n\t\t\t\t\tthis.formatHandler.detectFormat(data) !== 'legacy' &&\n\t\t\t\t\ttag === 'master'\n\t\t\t\t) {\n\t\t\t\t\t// Standard format - mark for file deletion after lock release\n\t\t\t\t\tshouldDeleteFile = true;\n\t\t\t\t\treturn data; // Return unchanged, we'll delete the file after\n\t\t\t\t}\n\n\t\t\t\tif (this.formatHandler.detectFormat(data) === 'legacy') {\n\t\t\t\t\t// Legacy format - remove the tag key\n\t\t\t\t\tif (tag in data) {\n\t\t\t\t\t\tdelete data[tag];\n\t\t\t\t\t\treturn data;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error(`Tag ${tag} not found`);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`Tag ${tag} not found in standard format`);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// Delete the file if we're removing master tag from standard format\n\t\t\tif (shouldDeleteFile) {\n\t\t\t\tawait this.fileOps.deleteFile(filePath);\n\t\t\t}\n\t\t} catch (error: any) {\n\t\t\tif (error.code === 'ENOENT') {\n\t\t\t\tthrow new Error(`Tag ${tag} not found - file doesn't exist`);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n","sourceCodeStart":712,"sourceCodeEnd":748,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts#L712-L748","documentation":"deleteTag, operating on a legacy-format tasks.json, deletes the given tag key only if it exists; otherwise it throws this plain Error. Tag names act as top-level keys, and deleting a nonexistent key would silently no-op, so the library makes the absence explicit.","triggerScenarios":"storage.deleteTag('old-tag') when 'old-tag' is not a key in the legacy tasks.json; deleting a tag already removed by another process; deleting with different casing than the stored key; calling deleteTag for 'master' while the file is in standard format is a different path (see error 216).","commonSituations":"Cleanup scripts running twice; stale tag lists cached from before a teammate deleted the tag; case-sensitivity mismatches between tag references; tags lost after a manual file edit or merge conflict resolution.","solutions":["Enumerate tags first (getTagsWithStats) and only delete when the tag is present.","Catch the error and treat it as success if your workflow requires idempotent deletion.","Verify exact tag spelling and case — keys are matched with the 'in' operator, so case matters.","Confirm the file is in legacy format; in standard format only 'master' can be deleted this way."],"exampleFix":"// before\nawait storage.deleteTag('old-tag');\n// after\nconst { tags } = await storage.getTagsWithStats();\nif (tags.some((t) => t.name === 'old-tag')) {\n  await storage.deleteTag('old-tag');\n}","handlingStrategy":"try-catch","validationCode":"const { tags } = await storage.getTagsWithStats();\nif (!tags.some((t) => t.name === tag)) return; // nothing to delete","typeGuard":"function hasTag(tagList: Array<{ name: string }>, name: string): boolean {\n  return tagList.some((t) => t.name === name);\n}","tryCatchPattern":"try {\n  await storage.deleteTag(tag);\n} catch (err) {\n  if (err instanceof Error && err.message === `Tag ${tag} not found`) {\n    return; // idempotent delete\n  }\n  throw err;\n}","preventionTips":["Refresh the tag list immediately before deleting; tags can be removed concurrently.","Match tag names exactly — key lookup is case-sensitive.","Make cleanup scripts idempotent so double runs don't fail.","Confirm the file is in legacy format before deleting non-master tags."],"tags":["tag-management","not-found","file-storage","delete"],"backgroundTag":"tag-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}