{"record":{"id":"d47f40db547edcd3","repo":"eyaltoledano/claude-task-master","slug":"tag-tag-not-found-file-doesn-t-exist","errorCode":null,"errorMessage":"Tag ${tag} not found - file doesn't exist","messagePattern":"Tag (.+?) not found - file doesn't exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts","lineNumber":743,"sourceCode":"\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\n\t/**\n\t * Rename a tag within the single tasks.json file\n\t * Uses modifyJson for atomic read-modify-write to prevent lost updates\n\t */\n\tasync renameTag(oldTag: string, newTag: string): Promise<void> {\n\t\tconst filePath = this.pathResolver.getTasksPath();\n\n\t\ttry {\n\t\t\tawait this.fileOps.modifyJson(filePath, (existingData: any) => {\n\t\t\t\tif (this.formatHandler.detectFormat(existingData) === 'legacy') {\n\t\t\t\t\t// Legacy format - rename the tag key\n\t\t\t\t\tif (oldTag in existingData) {\n\t\t\t\t\t\texistingData[newTag] = existingData[oldTag];","sourceCodeStart":725,"sourceCodeEnd":761,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts#L725-L761","documentation":"deleteTag wraps modifyJson in a try/catch; an ENOENT from the underlying read means tasks.json itself does not exist, and it is rethrown as \"Tag X not found - file doesn't exist\". This tells you the tag cannot exist because the entire storage file is absent — a bootstrap problem, not a tag-listing problem.","triggerScenarios":"storage.deleteTag('x') in a directory with no tasks.json; wrong project root or misconfigured path so the resolver points at a nonexistent file; file deleted between listing and deletion; running tag cleanup in CI on a fresh checkout without init.","commonSituations":"Gitignored tasks.json missing after clone; CLI run from the wrong working directory; automated cleanup scheduled before project initialization; path env var pointing to a stale location.","solutions":["Initialize the project to create tasks.json before running tag operations.","Check that the storage path (cwd / env override) resolves to the directory containing tasks.json.","Catch this error and short-circuit tag-cleanup routines when the file is missing.","Restore tasks.json from backup or regenerate it if it was accidentally deleted."],"exampleFix":"// before\nawait storage.deleteTag('stale');\n// after\nif (!fs.existsSync(tasksPath)) {\n  console.warn('tasks.json missing; skipping tag cleanup');\n  return;\n}\nawait storage.deleteTag('stale');","handlingStrategy":"validation","validationCode":"import fs from 'fs';\nif (!fs.existsSync(tasksPath)) {\n  console.warn(`tasks.json missing at ${tasksPath}; skipping tag deletion`);\n  return;\n}\nawait storage.deleteTag(tag);","typeGuard":"function fileExists(p: string): boolean {\n  try { return fs.statSync(p).isFile(); } catch { return false; }\n}","tryCatchPattern":"try {\n  await storage.deleteTag(tag);\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"file doesn't exist\")) {\n    console.warn('tasks.json absent — nothing to clean up');\n    return;\n  }\n  throw err;\n}","preventionTips":["Initialize the project before scheduling tag cleanup jobs.","Run CLI/storage operations from the correct project root.","Gitignore-aware onboarding: init after clone since tasks.json may not be committed.","Treat 'file doesn't exist' tag errors as no-ops in cleanup automation."],"tags":["file-storage","missing-file","tag-management","initialization"],"backgroundTag":"tasks-file-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}