{"record":{"id":"ff9bbb2e3aae29c4","repo":"eyaltoledano/claude-task-master","slug":"parent-task-parentid-has-no-subtasks-ff9bbb","errorCode":null,"errorMessage":"Parent task ${parentId} has no subtasks.","messagePattern":"Parent task (.+?) has no subtasks\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/update-subtask-by-id.js","lineNumber":163,"sourceCode":"\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}\n\n\t\tconst parentTask = data.tasks.find((task) => task.id === parentId);\n\t\tif (!parentTask) {\n\t\t\tthrow new Error(\n\t\t\t\t`Parent task with ID ${parentId} not found. Please verify the task ID and try again.`\n\t\t\t);\n\t\t}\n\n\t\tif (!parentTask.subtasks || !Array.isArray(parentTask.subtasks)) {\n\t\t\tthrow new Error(`Parent task ${parentId} has no subtasks.`);\n\t\t}\n\n\t\tconst subtaskIndex = parentTask.subtasks.findIndex(\n\t\t\t(st) => st.id === subtaskIdNum\n\t\t);\n\t\tif (subtaskIndex === -1) {\n\t\t\tthrow new Error(\n\t\t\t\t`Subtask with ID ${subtaskId} not found. Please verify the subtask ID and try again.`\n\t\t\t);\n\t\t}\n\n\t\tconst subtask = parentTask.subtasks[subtaskIndex];\n\n\t\t// --- Metadata-Only Update (Fast Path) ---\n\t\t// If only metadata is provided (no prompt), skip AI and just update metadata\n\t\tif (metadata && (!prompt || prompt.trim() === '')) {\n\t\t\treport('info', `Metadata-only update for subtask ${subtaskId}`);\n\t\t\t// Merge new metadata with existing","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/update-subtask-by-id.js#L145-L181","documentation":"updateSubtaskById() validates that the parent task exists and that its subtasks array is present before locating the target subtask. This error is thrown when the parent task exists but has no subtasks array (missing or not an array), so there is nothing to update. It is a data-integrity guard against malformed tasks.json entries.","triggerScenarios":"Calling updateSubtaskById with a subtask ID like '5.2' where task 5 exists but has no subtasks array (e.g., an empty or manually-edited tasks.json, or task 5 never had subtasks created).","commonSituations":"Typos in the parent ID (meant 5.2 but task 5 has no children); hand-editing or migrating tasks.json and dropping the subtasks field; calling with a display/numeric parent ID assuming subtasks exist; stale file after another process rewrote tasks.","solutions":["Run 'task-master list' (or read tasks.json) to confirm the parent task actually has subtasks","Check the ID format: use parent.subtask (e.g., 5.2); if you meant a top-level task, call update-task-by-id instead","Use 'task-master expand <id>' to generate subtasks for the parent before updating","Repair the tasks.json entry so subtasks is an array (backup first)"],"exampleFix":"// before\nawait updateSubtaskById('5.2', prompt);\n// after\nconst parent = tasks.find(t => t.id === 5);\nif (parent?.subtasks?.length) {\n  await updateSubtaskById('5.2', prompt);\n} else {\n  await expandTask(5); // create subtasks first\n}","handlingStrategy":"validation","validationCode":"const parent = data.tasks.find(t => t.id === parentIdNum);\nif (!parent) throw new Error(`Task ${parentId} not found`);\nif (!Array.isArray(parent.subtasks) || parent.subtasks.length === 0) {\n  throw new Error(`Task ${parentId} has no subtasks`);\n}","typeGuard":"function hasSubtasks(task) {\n  return Array.isArray(task?.subtasks) && task.subtasks.length > 0;\n}","tryCatchPattern":"try {\n  await updateSubtaskById('5.2', prompt);\n} catch (err) {\n  if (err.message.includes('has no subtasks')) {\n    await expandTask(5); // generate subtasks, then retry\n  } else throw err;\n}","preventionTips":["Always check the parent task's subtasks array before calling update-subtask-by-id","Use 'task-master list --with-subtasks' to confirm IDs before scripted updates","Never hand-edit tasks.json without validating the resulting shape","Prefer 'task-master expand' to create subtasks rather than manual edits"],"tags":["task-management","validation","subtasks","not-found"],"backgroundTag":"subtask-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}