{"record":{"id":"b8680c2311177c77","repo":"eyaltoledano/claude-task-master","slug":"tag-tag-not-found-or-has-no-tasks","errorCode":null,"errorMessage":"Tag '${tag}' not found or has no tasks.","messagePattern":"Tag '(.+?)' not found or has no tasks\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/remove-task.js","lineNumber":45,"sourceCode":"\n\tif (taskIdsToRemove.length === 0) {\n\t\tresults.success = false;\n\t\tresults.errors.push('No valid task IDs provided.');\n\t\treturn results;\n\t}\n\n\ttry {\n\t\t// Read the tasks file ONCE before the loop, preserving the full tagged structure\n\t\tconst rawData = readJSON(tasksPath, projectRoot, tag); // Read raw data\n\t\tif (!rawData) {\n\t\t\tthrow new Error(`Could not read tasks file at ${tasksPath}`);\n\t\t}\n\n\t\t// Use the full tagged data if available, otherwise use the data as is\n\t\tconst fullTaggedData = rawData._rawTaggedData || rawData;\n\n\t\tif (!fullTaggedData[tag] || !fullTaggedData[tag].tasks) {\n\t\t\tthrow new Error(`Tag '${tag}' not found or has no tasks.`);\n\t\t}\n\n\t\tconst tasks = fullTaggedData[tag].tasks; // Work with tasks from the correct tag\n\n\t\tconst tasksToDeleteFiles = []; // Collect IDs of main tasks whose files should be deleted\n\n\t\tfor (const taskId of taskIdsToRemove) {\n\t\t\t// Check if the task ID exists *before* attempting removal\n\t\t\tif (!taskExists(tasks, taskId)) {\n\t\t\t\tconst errorMsg = `Task with ID ${taskId} in tag '${tag}' not found or already removed.`;\n\t\t\t\tresults.errors.push(errorMsg);\n\t\t\t\tresults.success = false; // Mark overall success as false if any error occurs\n\t\t\t\tcontinue; // Skip to the next ID\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\t// Handle subtask removal (e.g., '5.2')\n\t\t\t\tif (typeof taskId === 'string' && taskId.includes('.')) {","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/remove-task.js#L27-L63","documentation":"removeTask works on the full tagged tasks.json structure. After resolving the tag (explicit option or active tag), if fullTaggedData has no entry for that tag or the tag entry has no tasks array, this error is thrown.","triggerScenarios":"Calling removeTask while the resolved tag (e.g. 'feature-x') does not exist in tasks.json, or the tag exists as an empty object without tasks, or reading legacy untagged files where the expected tag key is absent.","commonSituations":"Typo in --tag name, removing tasks in a tag created later deleted, legacy tasks.json without tag structure being accessed with a non-default tag, tag renamed via task-master tags while old scripts still reference it.","solutions":["Run 'task-master tags' to list valid tags and use the correct one with --tag.","Remove the task under the existing 'master' tag if you did not intend a custom tag.","Create the missing tag with 'task-master tags create <name>' before operating on it.","Migrate legacy untagged tasks.json to tagged format if required."],"exampleFix":"// before\ntask-master remove-task --i=5 --tag=featuer-x\n// after\ntask-master remove-task --i=5 --tag=feature-x","handlingStrategy":"validation","validationCode":"const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));\nconst activeTag = tag ?? data.activeTag ?? 'master';\nif (!data[activeTag]?.tasks) {\n  throw new Error(`Tag '${activeTag}' missing or empty. Valid tags: ${Object.keys(data).filter((k) => data[k]?.tasks).join(', ')}`);\n}","typeGuard":"function tagHasTasks(data, tag) {\n  return data != null && Array.isArray(data[tag]?.tasks);\n}","tryCatchPattern":"try {\n  await tmCore.tasks.removeTask(tasksPath, ids, { tag });\n} catch (err) {\n  if (err.message.includes('not found or has no tasks')) {\n    console.error(`Tag '${tag}' does not exist or is empty. Run 'task-master tags' to list tags.`);\n  } else throw err;\n}","preventionTips":["Run 'task-master tags' to confirm the tag name before use.","Beware typos in --tag values; tab-complete or copy from tags output.","Recreate tags deleted by teammates before operating on them.","Prefer the explicit default 'master' tag when unsure."],"tags":["validation","tag","not-found"],"backgroundTag":"tag-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}