{"record":{"id":"3e0e0bce90876674","repo":"eyaltoledano/claude-task-master","slug":"no-valid-tasks-found-in-taskspath-the-file-may","errorCode":null,"errorMessage":"No valid tasks found in ${tasksPath}. The file may be corrupted or have an invalid format.","messagePattern":"No valid tasks found in (.+?)\\. The file may be corrupted or have an invalid format\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/update-subtask-by-id.js","lineNumber":135,"sourceCode":"\t\t\t};\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, validate the subtask ID format (must contain a dot)\n\t\tif (!subtaskId.includes('.')) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid subtask ID format: ${subtaskId}. In solo mode, subtask ID must be in format \"parentId.subtaskId\" (e.g., \"5.2\").`\n\t\t\t);\n\t\t}\n\n\t\tif (!fs.existsSync(tasksPath)) {\n\t\t\tthrow new Error(`Tasks file not found at path: ${tasksPath}`);\n\t\t}\n\n\t\tconst data = readJSON(tasksPath, projectRoot, tag);\n\t\tif (!data || !data.tasks) {\n\t\t\tthrow new Error(\n\t\t\t\t`No valid tasks found in ${tasksPath}. The file may be corrupted or have an invalid format.`\n\t\t\t);\n\t\t}\n\n\t\tconst [parentIdStr, subtaskIdStr] = subtaskId.split('.');\n\t\tconst parentId = parseInt(parentIdStr, 10);\n\t\tconst subtaskIdNum = parseInt(subtaskIdStr, 10);\n\n\t\tif (\n\t\t\tNumber.isNaN(parentId) ||\n\t\t\tparentId <= 0 ||\n\t\t\tNumber.isNaN(subtaskIdNum) ||\n\t\t\tsubtaskIdNum <= 0\n\t\t) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid subtask ID format: ${subtaskId}. Both parent ID and subtask ID must be positive integers.`\n\t\t\t);\n\t\t}","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-subtask-by-id.js#L117-L153","documentation":"readJSON succeeded but returned null/undefined or an object without a tasks array, so the file content is unusable. This guards against corrupted or structurally invalid tasks.json files.","triggerScenarios":"tasks.json containing invalid JSON, an empty object, or JSON without a top-level tasks array; partial writes truncating the file.","commonSituations":"Manual edits to tasks.json that broke the schema, merge conflicts resolved incorrectly, disk-full or interrupted writes, schema drift between task-master versions.","solutions":["Inspect tasks.json and fix or restore valid JSON with a top-level tasks array","Restore from git: git checkout -- .taskmanager/tasks.json or a backup","Rebuild via 'task-master generate' or re-run init if unrecoverable"],"exampleFix":"// before\n// tasks.json: { \"notes\": [] }  (no tasks array)\n// after\n// tasks.json: { \"tasks\": [ { \"id\": 1, \"title\": \"...\", \"status\": \"pending\" } ] }","handlingStrategy":"validation","validationCode":"const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));\nif (!data || !Array.isArray(data.tasks)) {\n  throw new Error(`${tasksPath} has no tasks array`);\n}","typeGuard":"function hasValidTasksData(v) {\n  return v !== null && typeof v === 'object' && Array.isArray(v.tasks);\n}","tryCatchPattern":"try {\n  await updateSubtaskById(subtaskId, prompt, options);\n} catch (err) {\n  if (err.message.includes('No valid tasks found')) {\n    console.error('Restore tasks.json from git or regenerate it');\n  } else throw err;\n}","preventionTips":["Never hand-edit tasks.json without validating JSON afterwards","Keep tasks.json in version control for easy restore","Validate schema after merges and version upgrades"],"tags":["filesystem","data-corruption","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}