{"record":{"id":"b5791bb70474bc39","repo":"eyaltoledano/claude-task-master","slug":"tasks-file-not-found-taskspath","errorCode":null,"errorMessage":"Tasks file not found: ${tasksPath}","messagePattern":"Tasks file not found: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/update-task-by-id.js","lineNumber":130,"sourceCode":"\t\t\ttag,\n\t\t\tappendMode,\n\t\t\tuseResearch,\n\t\t\tmetadata,\n\t\t\tisMCP,\n\t\t\toutputFormat,\n\t\t\treport\n\t\t});\n\n\t\t// If remote handled it, return the result\n\t\tif (remoteResult) {\n\t\t\treturn remoteResult;\n\t\t}\n\t\t// Otherwise fall through to file-based logic below\n\t\t// --- End BRIDGE ---\n\n\t\t// For file storage, ensure the tasks file exists\n\t\tif (!fs.existsSync(tasksPath))\n\t\t\tthrow new Error(`Tasks file not found: ${tasksPath}`);\n\t\t// --- End Input Validations ---\n\n\t\t// --- Task Loading and Status Check (Keep existing) ---\n\t\tconst data = readJSON(tasksPath, projectRoot, tag);\n\t\tif (!data || !data.tasks)\n\t\t\tthrow new Error(`No valid tasks found in ${tasksPath}.`);\n\t\t// File storage requires a strict numeric task ID\n\t\tconst idStr = String(taskId).trim();\n\t\tif (!/^\\d+$/.test(idStr)) {\n\t\t\tthrow new Error(\n\t\t\t\t'For file storage, taskId must be a positive integer. ' +\n\t\t\t\t\t'Use update-subtask-by-id for IDs like \"1.2\", or run in API storage for display IDs (e.g., \"HAM-123\").'\n\t\t\t);\n\t\t}\n\t\tconst numericTaskId = Number(idStr);\n\t\tconst taskIndex = data.tasks.findIndex((task) => task.id === numericTaskId);\n\t\tif (taskIndex === -1) {\n\t\t\treport('error', `Task with ID ${numericTaskId} not found`);","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-task-by-id.js#L112-L148","documentation":"In file-storage mode, updateTaskById() checks that the tasks file (tasks.json at the resolved path for the current tag) exists before reading it. This error is thrown when fs.existsSync(tasksPath) is false, i.e., the tasks file has not been created or the path/tag resolves to a nonexistent file.","triggerScenarios":"Running update before task-master init / parse-prd ever created tasks.json; a custom or wrong tag resolving to .taskmaster/tasks/<tag>.json that does not exist; wrong project root so the resolved path points nowhere.","commonSituations":"Fresh clones without initialization; switching to a new tag before creating tasks in it; CI checkouts that exclude .taskmaster; typos in --file or tag options pointing at a missing file.","solutions":["Run 'task-master init' and 'task-master parse-prd' to generate tasks.json, or create the tasks file","Verify the active tag: run 'task-master list' or check .taskmaster/tasks/ for the tag's file","Confirm the project root is correct so tasksPath resolves to the real file","Restore tasks.json from version control or backup if it was deleted"],"exampleFix":"// before\nawait updateTaskById(5, prompt); // tasks.json missing\n// after\nimport fs from 'fs';\nconst tasksPath = '.taskmaster/tasks/tasks.json';\nif (!fs.existsSync(tasksPath)) {\n  await run('task-master parse-prd prd.txt');\n}\nawait updateTaskById(5, prompt);","handlingStrategy":"validation","validationCode":"import fs from 'fs';\nconst tasksPath = '.taskmaster/tasks/tasks.json'; // or resolveTasksPath(tag)\nif (!fs.existsSync(tasksPath)) {\n  throw new Error(`Initialize first: task-master init && task-master parse-prd prd.txt (missing ${tasksPath})`);\n}","typeGuard":"function tasksFileExists(path) {\n  return typeof path === 'string' && fs.existsSync(path);\n}","tryCatchPattern":"try {\n  await updateTaskById(5, prompt);\n} catch (err) {\n  if (err.message.startsWith('Tasks file not found')) {\n    await runInitAndParsePrd(); // create tasks.json, then retry once\n  } else throw err;\n}","preventionTips":["Initialize the project (task-master init + parse-prd) before any update commands","Confirm the active tag has a corresponding file under .taskmaster/tasks/","Ensure .taskmaster is committed or generated in CI before running scripts","Verify the resolved tasksPath when using custom file paths or tags"],"tags":["filesystem","task-management","file-not-found","configuration"],"backgroundTag":"tasks-json-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}