{"record":{"id":"927a59c0359144fa","repo":"eyaltoledano/claude-task-master","slug":"could-not-read-tasks-file-at-taskspath-927a59","errorCode":null,"errorMessage":"Could not read tasks file at ${tasksPath}","messagePattern":"Could not read tasks file at (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/tag-management.js","lineNumber":107,"sourceCode":"\t\t// Validate tag name format (alphanumeric, hyphens, underscores only)\n\t\tif (!/^[a-zA-Z0-9_-]+$/.test(tagName)) {\n\t\t\tthrow new Error(\n\t\t\t\t'Tag name can only contain letters, numbers, hyphens, and underscores'\n\t\t\t);\n\t\t}\n\n\t\t// Reserved tag names\n\t\tconst reservedNames = ['master', 'main', 'default'];\n\t\tif (reservedNames.includes(tagName.toLowerCase())) {\n\t\t\tthrow new Error(`\"${tagName}\" is a reserved tag name`);\n\t\t}\n\n\t\tlogFn.info(`Creating new tag: ${tagName}`);\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 - ensure we get the actual tagged structure\n\t\tlet rawData;\n\t\tif (data._rawTaggedData) {\n\t\t\t// If we have _rawTaggedData, use it (this is the clean tagged structure)\n\t\t\trawData = data._rawTaggedData;\n\t\t} else if (data.tasks && !data.master) {\n\t\t\t// This is legacy format - create a master tag structure\n\t\t\trawData = {\n\t\t\t\tmaster: {\n\t\t\t\t\ttasks: data.tasks,\n\t\t\t\t\tmetadata: data.metadata || {\n\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}","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/tag-management.js#L89-L125","documentation":"createTag reads the tasks file with readJSON and throws this error if the read returns null/falsy, meaning the file does not exist, is unparsable, or is empty. Tag operations require the existing tagged structure, so a missing store is fatal.","triggerScenarios":"Calling createTag with a tasksPath where .taskmaster/tasks/tasks.json has not been initialized (no tasks parsed yet), the JSON is corrupted by a failed merge, or the path is wrong.","commonSituations":"Running add-tag in a fresh repo before 'task-master parse-prd'; merge conflicts leaving invalid JSON; CI checkout missing the .taskmaster directory; passing an incorrect --file path.","solutions":["Verify the tasks file exists at the given tasksPath (default .taskmaster/tasks/tasks.json)","Validate/repair the JSON (e.g. with a JSON linter) — fix merge-conflict markers","Initialize tasks first: run 'task-master parse-prd' or 'task-master init' before creating tags","Confirm the --file / tasksPath argument points to the correct file"],"exampleFix":"// before\ntask-master add-tag sprint-1   // fresh repo, no tasks.json\n// after\ntask-master parse-prd prd.txt  // creates tasks.json\ntask-master add-tag sprint-1","handlingStrategy":"validation","validationCode":"import fs from 'fs';\nif (!fs.existsSync(tasksPath)) {\n  throw new Error(`Tasks file missing at ${tasksPath}; run 'task-master parse-prd' or 'task-master init' first`);\n}\nJSON.parse(fs.readFileSync(tasksPath, 'utf8')); // throws on corrupt JSON","typeGuard":"function tasksFileReadable(data) {\n  return Boolean(data) && typeof data === 'object';\n}","tryCatchPattern":"try {\n  await createTag(tasksPath, name, {});\n} catch (err) {\n  if (err.message.startsWith('Could not read tasks file')) {\n    console.error(`Ensure ${tasksPath} exists and is valid JSON (init/parse-prd first).`);\n  } else throw err;\n}","preventionTips":["Initialize the project (init/parse-prd) before any tag operations in fresh repos","Check tasks.json into version control so CI checkouts have it","Run a JSON lint step after merges touching tasks.json","Confirm the --file path argument matches the actual file location"],"tags":["file-io","missing-file","tagging"],"backgroundTag":"missing-tasks-file","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}