{"record":{"id":"7c3410b1c8cd4a0b","repo":"eyaltoledano/claude-task-master","slug":"invalid-tasks-file-or-tag-tag-not-found-at","errorCode":null,"errorMessage":"Invalid tasks file or tag \"${tag}\" not found at ${tasksPath}","messagePattern":"Invalid tasks file or tag \"(.+?)\" not found at (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/set-task-status.js","lineNumber":67,"sourceCode":"\t\t\t\t\tborderStyle: 'round'\n\t\t\t\t})\n\t\t\t);\n\t\t}\n\n\t\tlog('info', `Reading tasks from ${tasksPath}...`);\n\n\t\t// Read the raw data without tag resolution to preserve tagged structure\n\t\tlet rawData = readJSON(tasksPath, projectRoot, tag); // No tag parameter\n\n\t\t// Handle the case where readJSON returns resolved data with _rawTaggedData\n\t\tif (rawData && rawData._rawTaggedData) {\n\t\t\t// Use the raw tagged data and discard the resolved view\n\t\t\trawData = rawData._rawTaggedData;\n\t\t}\n\n\t\t// Ensure the tag exists in the raw data\n\t\tif (!rawData || !rawData[tag] || !Array.isArray(rawData[tag].tasks)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid tasks file or tag \"${tag}\" not found at ${tasksPath}`\n\t\t\t);\n\t\t}\n\n\t\t// Get the tasks for the current tag\n\t\tconst data = {\n\t\t\ttasks: rawData[tag].tasks,\n\t\t\ttag,\n\t\t\t_rawTaggedData: rawData\n\t\t};\n\n\t\tif (!data || !data.tasks) {\n\t\t\tthrow new Error(`No valid tasks found in ${tasksPath}`);\n\t\t}\n\n\t\t// Handle multiple task IDs (comma-separated)\n\t\tconst taskIds = taskIdInput.split(',').map((id) => id.trim());\n\t\tconst updatedTasks = [];","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/set-task-status.js#L49-L85","documentation":"After loading the tasks file, setTaskStatus verifies that the resolved raw data actually contains an entry for the given tag with a tasks array. If the file is unreadable/corrupt or the tag key is missing, it throws this error. It protects against operating on a nonexistent tag context.","triggerScenarios":"Calling setTaskStatus with options.tag set to a tag that was never created, passing a tasksPath pointing to a malformed/empty JSON file, or reading raw data where the tag array was removed by hand editing.","commonSituations":"Typos in --tag ('feature-auth' vs 'featureauth'); fresh repos where only 'master' exists; hand-edited tasks.json dropping a tag; wrong tasksPath passed in scripts.","solutions":["Run 'task-master tags' to list existing tags and use one that exists","Create the tag first with 'task-master add-tag <name>'","Verify the tasksPath points to a valid .taskmaster/tasks/tasks.json containing the tag key","Omit the tag option to use the current/default tag"],"exampleFix":"// before\nawait setTaskStatus(tasksPath, '1', 'done', { tag: 'release' }); // tag absent\n// after\nawait setTaskStatus(tasksPath, '1', 'done'); // uses current tag","handlingStrategy":"validation","validationCode":"const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));\nif (tag && !(tag in data)) {\n  throw new Error(`Tag '${tag}' not found. Available: ${Object.keys(data).filter((k) => data[k]?.tasks).join(', ')}`);\n}","typeGuard":"function tagExists(rawData, tag) {\n  return Boolean(rawData && rawData[tag] && Array.isArray(rawData[tag].tasks));\n}","tryCatchPattern":"try {\n  await setTaskStatus(tasksPath, id, status, { tag });\n} catch (err) {\n  if (err.message.includes('not found at')) {\n    console.error(`Tag '${tag}' missing — run 'task-master tags' to list, or 'add-tag ${tag}' to create.`);\n  } else throw err;\n}","preventionTips":["List tags before referencing one in scripts or CI","Avoid hand-editing tasks.json; use add-tag/delete-tag commands","Keep the default tag when unsure instead of passing an explicit tag","Commit a valid tasks.json so fresh checkouts contain all expected tags"],"tags":["tagging","not-found","file-validation"],"backgroundTag":"tag-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}