{"record":{"id":"f68f1cbdefa1a05d","repo":"eyaltoledano/claude-task-master","slug":"tag-targettag-not-found","errorCode":null,"errorMessage":"Tag \"${targetTag}\" not found.","messagePattern":"Tag \"(.+?)\" not found\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/add-task.js","lineNumber":268,"sourceCode":"\t\t\t// Do not write the file here; it will be written later with the new task.\n\n\t\t\t// Perform complete migration (config.json, state.json)\n\t\t\tperformCompleteTagMigration(tasksPath);\n\t\t\tmarkMigrationForNotice(tasksPath);\n\n\t\t\treport('Successfully migrated to tagged format.', 'success');\n\t\t}\n\n\t\t// Use the provided tag, or the current active tag, or default to 'master'\n\t\tconst targetTag = tag;\n\n\t\t// Ensure the target tag exists\n\t\tif (!rawData[targetTag]) {\n\t\t\treport(\n\t\t\t\t`Tag \"${targetTag}\" does not exist. Please create it first using the 'add-tag' command.`,\n\t\t\t\t'error'\n\t\t\t);\n\t\t\tthrow new Error(`Tag \"${targetTag}\" not found.`);\n\t\t}\n\n\t\t// Ensure the target tag has a tasks array and metadata object\n\t\tif (!rawData[targetTag].tasks) {\n\t\t\trawData[targetTag].tasks = [];\n\t\t}\n\t\tif (!rawData[targetTag].metadata) {\n\t\t\trawData[targetTag].metadata = {\n\t\t\t\tcreated: new Date().toISOString(),\n\t\t\t\tupdated: new Date().toISOString(),\n\t\t\t\tdescription: ``\n\t\t\t};\n\t\t}\n\n\t\t// Get a flat list of ALL tasks across ALL tags to validate dependencies\n\t\tconst allTasks = getAllTasks(rawData);\n\n\t\t// Find the highest task ID *within the target tag* to determine the next ID","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/add-task.js#L250-L286","documentation":"addTask writes new tasks into a specific tag's task list within the multi-tag tasks file; this error is thrown when the target tag key does not exist in the raw data. Tags act as isolated task collections, so writing to a nonexistent tag is refused instead of silently creating it.","triggerScenarios":"Calling addTask with a targetTag that has never been created, e.g. after switching tags or typos in --tag flags.","commonSituations":"Users forgetting to run 'add-tag' before adding tasks to a new tag, mistyping tag names, or referencing tags that exist only in another environment's tasks file.","solutions":["Create the tag first: run 'task-master add-tag <name>' (or the equivalent API).","Verify the exact tag name in your tasks file — check for typos or case differences.","List existing tags to confirm which are available.","Re-run addTask with the correct existing tag."],"exampleFix":"// before\nawait addTask({ prompt: 'New task', tag: 'release-2' }); // tag missing\n// after\nawait tmCore.tags.create('release-2'); // or: task-master add-tag release-2\nawait addTask({ prompt: 'New task', tag: 'release-2' });","handlingStrategy":"validation","validationCode":"const rawData = readJSON(tasksPath, projectRoot);\nif (!rawData[targetTag]) {\n  throw new Error(`Tag \"${targetTag}\" missing — run add-tag first`);\n}","typeGuard":"function tagExists(rawData, tag) {\n  return Object.prototype.hasOwnProperty.call(rawData ?? {}, tag);\n}","tryCatchPattern":"try {\n  await addTask({ prompt, tag: targetTag });\n} catch (err) {\n  if (err.message.startsWith('Tag \"') && err.message.includes('not found')) {\n    const tag = err.message.match(/Tag \"(.+)\" not found/)?.[1];\n    // create the tag, then retry once\n  } else throw err;\n}","preventionTips":["Create tags with add-tag before targeting them","Keep tag names in shared constants to avoid typos","List tags before scripted task creation","Sync tag definitions across environments before running batch jobs"],"tags":["tags","not-found","configuration","tasks"],"backgroundTag":"tag-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}