{"record":{"id":"d7f8c80fd2ce4036","repo":"eyaltoledano/claude-task-master","slug":"tag-oldname-does-not-exist","errorCode":null,"errorMessage":"Tag \"${oldName}\" does not exist","messagePattern":"Tag \"(.+?)\" does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/tag-management.js","lineNumber":996,"sourceCode":"\t\tconst reservedNames = ['master', 'main', 'default'];\n\t\tif (reservedNames.includes(newName.toLowerCase())) {\n\t\t\tthrow new Error(`\"${newName}\" is a reserved tag name`);\n\t\t}\n\n\t\tlogFn.info(`Renaming tag from \"${oldName}\" to \"${newName}\"`);\n\n\t\t// Read current tasks data\n\t\tconst data = readJSON(tasksPath, projectRoot);\n\t\tif (!data) {\n\t\t\tthrow new Error(`Could not read tasks file at ${tasksPath}`);\n\t\t}\n\n\t\t// Use raw tagged data for tag operations\n\t\tconst rawData = data._rawTaggedData || data;\n\n\t\t// Check if old tag exists\n\t\tif (!rawData[oldName]) {\n\t\t\tthrow new Error(`Tag \"${oldName}\" does not exist`);\n\t\t}\n\n\t\t// Check if new tag name already exists\n\t\tif (rawData[newName]) {\n\t\t\tthrow new Error(`Tag \"${newName}\" already exists`);\n\t\t}\n\n\t\t// Get current tag to check if we're renaming the active tag\n\t\tconst currentTag = getCurrentTag(projectRoot);\n\t\tconst isCurrentTag = currentTag === oldName;\n\n\t\t// Rename the tag by copying data and deleting old\n\t\trawData[newName] = { ...rawData[oldName] };\n\n\t\t// Update metadata if it exists\n\t\tif (rawData[newName].metadata) {\n\t\t\trawData[newName].metadata.renamed = {\n\t\t\t\tfrom: oldName,","sourceCodeStart":978,"sourceCodeEnd":1014,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/tag-management.js#L978-L1014","documentation":"After loading the tagged data, renameTag() checks that the oldName key exists in rawData. If there is no tag with that name, this error is thrown. Tag names are exact string keys — matching is case-sensitive and no fuzzy lookup is performed.","triggerScenarios":"Calling renameTag with an oldName that was never created, was already renamed/deleted, or differs in case ('Backlog' vs 'backlog'); typos in the tag name.","commonSituations":"Renaming a tag twice (second call uses the pre-rename name); switching machines/branches where tasks.json has different tags; scripts hard-coding tag names that a teammate renamed; listing tags with task-master tags --list to discover valid names.","solutions":["Run `task-master tags` (or inspect tasks.json) and use the exact current tag name","Fix case-sensitivity: tag keys match exactly ('backlog' !== 'Backlog')","Create the tag first with createTag if it genuinely does not exist","Guard before calling: check the tag exists in the parsed tasks.json data"],"exampleFix":"// before\nawait renameTag(tasksPath, 'Backlog', 'todo');\n// after\nconst data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));\nif (!data['backlog']) throw new Error('tag backlog not found');\nawait renameTag(tasksPath, 'backlog', 'todo');","handlingStrategy":"validation","validationCode":"const data = JSON.parse(require('fs').readFileSync(tasksPath, 'utf8'));\nif (!Object.prototype.hasOwnProperty.call(data, oldName)) {\n  throw new Error(`Tag \"${oldName}\" does not exist. Available: ${Object.keys(data).join(', ')}`);\n}","typeGuard":"function tagExists(tasksData, name) {\n  return typeof name === 'string' && Object.prototype.hasOwnProperty.call(tasksData, name);\n}","tryCatchPattern":"try {\n  await renameTag(tasksPath, oldName, newName);\n} catch (err) {\n  if (err.message.includes('does not exist')) {\n    console.error(`Unknown tag \"${oldName}\" — run 'task-master tags' to list valid names`);\n    return;\n  }\n  throw err;\n}","preventionTips":["Discover tag names dynamically with `task-master tags` instead of hardcoding","Remember tag keys are case-sensitive; use the exact name shown in the list","After a rename, update any scripts that reference the old name","Guard with a hasOwnProperty check on parsed tasks.json before renaming"],"tags":["tag-management","validation","state-mismatch"],"backgroundTag":"resource-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}