{"record":{"id":"23eba0830222b941","repo":"eyaltoledano/claude-task-master","slug":"no-valid-tasks-found-in-taskspath-23eba0","errorCode":null,"errorMessage":"No valid tasks found in ${tasksPath}.","messagePattern":"No valid tasks found in (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/update-task-by-id.js","lineNumber":136,"sourceCode":"\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`);\n\t\t\tthrow new Error(`Task with ID ${numericTaskId} not found.`);\n\t\t}\n\t\tconst taskToUpdate = data.tasks[taskIndex];\n\t\tif (taskToUpdate.status === 'done' || taskToUpdate.status === 'completed') {\n\t\t\treport(\n\t\t\t\t'warn',","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-task-by-id.js#L118-L154","documentation":"After confirming the tasks file exists, updateTaskById() reads it with readJSON() and requires the parsed result to contain a tasks array. This error is thrown when the file is empty, unparseable, or its JSON lacks a tasks property, so there are no tasks to search or update.","triggerScenarios":"tasks.json contains {} or truncated JSON after a failed write or merge conflict; a manually-edited file dropped the tasks key; readJSON recovers from invalid JSON and returns null/undefined.","commonSituations":"Merge conflicts left conflict markers in tasks.json; an interrupted process wrote a partial file; hand-editing mistakes; another tool rewriting tasks.json in an incompatible shape.","solutions":["Inspect tasks.json and fix/restore valid JSON with a top-level tasks array (validate with a JSON parser)","Restore from git or a backup if the file was corrupted","Re-run 'task-master parse-prd' to regenerate tasks.json if contents are unrecoverable","Avoid concurrent writes to tasks.json; let Task Master manage the file","If this is a tag-specific file, check you are reading the right tag's file"],"exampleFix":"// before\n// tasks.json: { \"master\": { } }  // no tasks array\n// after\n// tasks.json: { \"tasks\": [ { \"id\": 1, \"title\": \"...\", \"subtasks\": [] } ] }","handlingStrategy":"validation","validationCode":"function assertValidTasksFile(tasksPath) {\n  let data;\n  try { data = JSON.parse(fs.readFileSync(tasksPath, 'utf8')); }\n  catch { throw new Error(`${tasksPath} is not valid JSON`); }\n  if (!data || !Array.isArray(data.tasks)) {\n    throw new Error(`${tasksPath} must contain a top-level tasks array`);\n  }\n  return data;\n}","typeGuard":"function hasTasksArray(data) {\n  return data !== null && typeof data === 'object' && Array.isArray(data.tasks);\n}","tryCatchPattern":"try {\n  await updateTaskById(5, prompt);\n} catch (err) {\n  if (err.message.startsWith('No valid tasks found')) {\n    console.error('tasks.json is empty/corrupt; restore from git or re-run parse-prd');\n  } else throw err;\n}","preventionTips":["Validate tasks.json after manual edits or merges (git hooks / JSON schema check)","Avoid concurrent writers to tasks.json; use Task Master commands for mutations","Commit tasks.json so corruption can be reverted","Watch for merge-conflict markers before running update commands"],"tags":["filesystem","task-management","json","data-corruption"],"backgroundTag":"tasks-json-invalid","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}