{"record":{"id":"5c767fcd42b2040f","repo":"eyaltoledano/claude-task-master","slug":"tag-tagname-already-exists","errorCode":null,"errorMessage":"Tag \"${tagName}\" already exists","messagePattern":"Tag \"(.+?)\" already exists","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/tag-management.js","lineNumber":139,"sourceCode":"\t\t\t\t\t\tcreated: new Date().toISOString(),\n\t\t\t\t\t\tupdated: new Date().toISOString(),\n\t\t\t\t\t\tdescription: 'Tasks live here by default'\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t} else {\n\t\t\t// This is already in tagged format, use it directly but exclude internal fields\n\t\t\trawData = {};\n\t\t\tfor (const [key, value] of Object.entries(data)) {\n\t\t\t\tif (key !== '_rawTaggedData' && key !== 'tag') {\n\t\t\t\t\trawData[key] = value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Check if tag already exists\n\t\tif (rawData[tagName]) {\n\t\t\tthrow new Error(`Tag \"${tagName}\" already exists`);\n\t\t}\n\n\t\t// Determine source for copying tasks (only if explicitly requested)\n\t\tlet sourceTasks = [];\n\t\tif (copyFromCurrent || copyFromTag) {\n\t\t\tconst sourceTag = copyFromTag || getCurrentTag(projectRoot);\n\t\t\tsourceTasks = getTasksForTag(rawData, sourceTag);\n\n\t\t\tif (copyFromTag && sourceTasks.length === 0) {\n\t\t\t\tlogFn.warn(`Source tag \"${copyFromTag}\" not found or has no tasks`);\n\t\t\t}\n\n\t\t\tlogFn.info(`Copying ${sourceTasks.length} tasks from tag \"${sourceTag}\"`);\n\t\t} else {\n\t\t\tlogFn.info('Creating empty tag (no tasks copied)');\n\t\t}\n\n\t\t// Create the new tag structure in raw data","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/tag-management.js#L121-L157","documentation":"Before writing, createTag checks the raw tagged data for an existing entry under the requested tagName. Duplicate tag names are not allowed, so attempting to create a tag that already exists throws this error. Names are compared as exact keys in the raw data object.","triggerScenarios":"Calling createTag with a name already present in tasks.json, e.g. re-running an idempotent-looking script, or creating 'feature-x' when 'feature-x' was created earlier; note the check is case-sensitive so 'Feature-X' would pass this check even if semantically similar.","commonSituations":"CI pipelines re-running tag creation steps without guards; team members independently creating the same sprint tag; automation deriving names that collide with existing tags.","solutions":["Check existing tags with 'task-master tags' and reuse the existing one","If the goal is to copy/refresh, use a versioned name (sprint-1, sprint-2)","In scripts, guard with an existence check before calling createTag"],"exampleFix":"// before\nawait createTag(tasksPath, 'sprint-1'); // throws if exists\n// after\nif (!rawData['sprint-1']) {\n  await createTag(tasksPath, 'sprint-1');\n}","handlingStrategy":"validation","validationCode":"const raw = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));\nif (raw[tagName]) {\n  console.log(`Tag '${tagName}' already exists — reusing it`);\n} else {\n  await createTag(tasksPath, tagName, {});\n}","typeGuard":"function tagIsNew(rawData, name) {\n  return Boolean(rawData) && !(name in rawData);\n}","tryCatchPattern":"try {\n  await createTag(tasksPath, name, {});\n} catch (err) {\n  if (err.message.includes('already exists')) {\n    console.log(`Tag '${name}' exists; proceeding with the existing tag.`);\n  } else throw err;\n}","preventionTips":["Make tag creation idempotent: check existence before creating","List tags ('task-master tags') as a preflight step in scripts/CI","Use versioned or date-suffixed tag names to avoid team collisions","Skip creation steps on pipeline re-runs instead of blindly re-creating"],"tags":["duplicate","tagging","validation"],"backgroundTag":"duplicate-resource","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}