{"record":{"id":"1c73812342bdf65e","repo":"eyaltoledano/claude-task-master","slug":"parent-task-parentid-has-no-subtasks","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/remove-subtask.js","lineNumber":50,"sourceCode":"\t\tif (!subtaskId.includes('.')) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid subtask ID format: ${subtaskId}. Expected format: \"parentId.subtaskId\"`\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\t// Find the parent task\n\t\tconst parentTask = data.tasks.find((t) => t.id === parentId);\n\t\tif (!parentTask) {\n\t\t\tthrow new Error(`Parent task with ID ${parentId} not found`);\n\t\t}\n\n\t\t// Check if parent has subtasks\n\t\tif (!parentTask.subtasks || parentTask.subtasks.length === 0) {\n\t\t\tthrow new Error(`Parent task ${parentId} has no subtasks`);\n\t\t}\n\n\t\t// Find the subtask to remove\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(`Subtask ${subtaskId} not found`);\n\t\t}\n\n\t\t// Get a copy of the subtask before removing it\n\t\tconst removedSubtask = { ...parentTask.subtasks[subtaskIndex] };\n\n\t\t// Remove the subtask from the parent\n\t\tparentTask.subtasks.splice(subtaskIndex, 1);\n\n\t\t// If parent has no more subtasks, remove the subtasks array\n\t\tif (parentTask.subtasks.length === 0) {","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/remove-subtask.js#L32-L68","documentation":"removeSubtask requires the located parent task to actually contain subtasks. If the parent's subtasks array is missing or empty, there is nothing to remove, so this error is thrown.","triggerScenarios":"Calling removeSubtask('3.1') where task 3 exists but has no subtasks (subtasks array absent or zero-length).","commonSituations":"The subtask was already removed in a previous run, expanding task 3 failed so subtasks were never created, confusing the parent's own ID with a subtask ID, another teammate/tool flattened the subtasks.","solutions":["Run 'task-master list --with-subtasks' (or show the parent) to confirm subtasks exist.","If the subtask was already removed, no action is needed — treat as no-op.","Re-run expand or add-subtask to create subtasks before attempting removal.","Verify you are on the correct tag where the subtasks live."],"exampleFix":"// before\ntask-master remove-subtask --i=3.1  // task 3 has no subtasks\n// after\ntask-master add-subtask --parent=3 --title=\"Fix bug\" && task-master remove-subtask --i=3.1","handlingStrategy":"validation","validationCode":"const parent = tasks.find((t) => t.id === parentId);\nconst subId = parseInt(subtaskId.split('.')[1], 10);\nconst hasSub = Array.isArray(parent?.subtasks) && parent.subtasks.some((s) => s.id === subId);\nif (!hasSub) throw new Error(`Task ${parentId} has no subtask ${subId}; nothing to remove`);","typeGuard":"function hasSubtasks(t) {\n  return Array.isArray(t?.subtasks) && t.subtasks.length > 0;\n}","tryCatchPattern":"try {\n  await tmCore.tasks.removeSubtask(tasksPath, subtaskId);\n} catch (err) {\n  if (err.message.includes('has no subtasks')) {\n    console.error('Parent has no subtasks — the subtask may already be removed; treat as no-op or create subtasks first.');\n  } else throw err;\n}","preventionTips":["Inspect subtasks with 'task-master show <parentId>' before removal.","Make removal scripts idempotent (skip when nothing to remove).","Confirm expand/add-subtask completed successfully before removing subtasks.","Check the correct tag; subtasks may exist only under another tag."],"tags":["validation","task-id","not-found"],"backgroundTag":"task-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}