{"record":{"id":"f9b97f10bb7b5f0a","repo":"eyaltoledano/claude-task-master","slug":"tag-oldtag-not-found-f9b97f","errorCode":null,"errorMessage":"Tag ${oldTag} 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":771,"sourceCode":"\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];\n\t\t\t\t\t\tdelete existingData[oldTag];\n\n\t\t\t\t\t\t// Update metadata tags array\n\t\t\t\t\t\tif (existingData[newTag].metadata) {\n\t\t\t\t\t\t\texistingData[newTag].metadata.tags = [newTag];\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn existingData;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthrow new Error(`Tag ${oldTag} not found`);\n\t\t\t\t\t}\n\t\t\t\t} else if (oldTag === 'master') {\n\t\t\t\t\t// Convert standard format to legacy when renaming master\n\t\t\t\t\tconst masterTasks = existingData.tasks || [];\n\t\t\t\t\tconst masterMetadata = existingData.metadata || {};\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\t[newTag]: {\n\t\t\t\t\t\t\ttasks: masterTasks,\n\t\t\t\t\t\t\tmetadata: { ...masterMetadata, tags: [newTag] }\n\t\t\t\t\t\t}\n\t\t\t\t\t};\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(`Tag ${oldTag} not found in standard format`);\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error: any) {\n\t\t\tif (error.code === 'ENOENT') {","sourceCodeStart":753,"sourceCodeEnd":789,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts#L753-L789","documentation":"renameTag, on a legacy-format tasks.json, renames the tag key only when oldTag is an existing key; otherwise it throws this error. Renaming requires the source tag to exist since the operation moves its tasks and metadata to the new key.","triggerScenarios":"storage.renameTag('old-name', 'new-name') when 'old-name' is not a key in the legacy file; renaming a tag after it was deleted or renamed by someone else; casing mismatch between the passed name and stored key; renaming a non-master tag while the file is standard format takes the other branch (see 219).","commonSituations":"Rename scripts run twice (second run's source no longer exists); tag renamed by a teammate concurrently; typos or case differences in tag names; tag list stale after merging branches that both touched tasks.json.","solutions":["Verify the source tag exists (getTagsWithStats) before renaming.","If the error occurs because a previous rename already succeeded, treat it as done — check whether newTag now exists.","Match exact spelling/case of the stored tag key.","If the file is standard format, only 'master' can be the rename source; migrate or rename master instead."],"exampleFix":"// before\nawait storage.renameTag('old-name', 'new-name');\n// after\nconst { tags } = await storage.getTagsWithStats();\nif (tags.some((t) => t.name === 'old-name')) {\n  await storage.renameTag('old-name', 'new-name');\n} else if (tags.some((t) => t.name === 'new-name')) {\n  // already renamed previously — no-op\n}","handlingStrategy":"validation","validationCode":"const { tags } = await storage.getTagsWithStats();\nif (!tags.some((t) => t.name === oldTag)) {\n  throw new Error(`Cannot rename: tag '${oldTag}' does not exist`);\n}","typeGuard":"function canRename(tagList: Array<{ name: string }>, oldTag: string): boolean {\n  return tagList.some((t) => t.name === oldTag);\n}","tryCatchPattern":"try {\n  await storage.renameTag(oldTag, newTag);\n} catch (err) {\n  if (err instanceof Error && err.message === `Tag ${oldTag} not found`) {\n    const { tags } = await storage.getTagsWithStats();\n    if (tags.some((t) => t.name === newTag)) return; // rename already happened\n    throw err;\n  }\n  throw err;\n}","preventionTips":["Check source-tag existence before renaming; renames are not idempotent.","Handle re-run scenarios by detecting that newTag already exists.","Use exact tag spelling/case — key matching is case-sensitive.","Serialize tag mutations across processes/teammates to avoid stale-name races."],"tags":["tag-management","not-found","rename","file-storage"],"backgroundTag":"tag-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}