{"record":{"id":"09dd8d16b977ba4e","repo":"eyaltoledano/claude-task-master","slug":"parent-task-parenttaskid-or-its-subtasks-not-fo","errorCode":null,"errorMessage":"Parent task ${parentTaskId} or its subtasks not found for subtask ${taskId}","messagePattern":"Parent task (.+?) or its subtasks not found for subtask (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/remove-task.js","lineNumber":71,"sourceCode":"\t\t\t// Check if the task ID exists *before* attempting removal\n\t\t\tif (!taskExists(tasks, taskId)) {\n\t\t\t\tconst errorMsg = `Task with ID ${taskId} in tag '${tag}' not found or already removed.`;\n\t\t\t\tresults.errors.push(errorMsg);\n\t\t\t\tresults.success = false; // Mark overall success as false if any error occurs\n\t\t\t\tcontinue; // Skip to the next ID\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\t// Handle subtask removal (e.g., '5.2')\n\t\t\t\tif (typeof taskId === 'string' && taskId.includes('.')) {\n\t\t\t\t\tconst [parentTaskId, subtaskId] = taskId\n\t\t\t\t\t\t.split('.')\n\t\t\t\t\t\t.map((id) => parseInt(id, 10));\n\n\t\t\t\t\t// Find the parent task\n\t\t\t\t\tconst parentTask = tasks.find((t) => t.id === parentTaskId);\n\t\t\t\t\tif (!parentTask || !parentTask.subtasks) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Parent task ${parentTaskId} or its subtasks not found for subtask ${taskId}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Find the subtask to remove\n\t\t\t\t\tconst subtaskIndex = parentTask.subtasks.findIndex(\n\t\t\t\t\t\t(st) => st.id === subtaskId\n\t\t\t\t\t);\n\t\t\t\t\tif (subtaskIndex === -1) {\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t`Subtask ${subtaskId} not found in parent task ${parentTaskId}`\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// Store the subtask info before removal\n\t\t\t\t\tconst removedSubtask = {\n\t\t\t\t\t\t...parentTask.subtasks[subtaskIndex],\n\t\t\t\t\t\tparentTaskId: parentTaskId","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/remove-task.js#L53-L89","documentation":"When removeTask receives a dot-notation ID (parent.subtaskId), it looks up the parent in the tag's tasks array and requires both the parent to exist and to have a subtasks array. If either check fails, this error is thrown.","triggerScenarios":"Calling removeTask('12.3') where no task with id 12 exists in the tag, or task 12 exists but has no subtasks property (it is a main task with no subtasks).","commonSituations":"Typo in parent ID, task already removed, wrong tag so the parent isn't present, confusing remove-task and remove-subtask semantics so a bare/invalid parent reference is passed.","solutions":["Confirm the parent ID with 'task-master list' in the active tag and correct the ID.","Add --tag to target the tag containing the parent task.","If the parent has no subtasks, you may want to remove the main task itself: remove-task <parentId>.","Use remove-subtask for dot-notation subtask removal if that matches your intent."],"exampleFix":"// before\ntask-master remove-task --i=12.3   // parent 12 missing\n// after\ntask-master remove-task --i=7.3 --tag=master  // corrected ID/tag","handlingStrategy":"validation","validationCode":"const [parentIdStr] = taskId.split('.');\nconst parentId = parseInt(parentIdStr, 10);\nconst tasks = data[tag]?.tasks ?? [];\nconst parent = tasks.find((t) => t.id === parentId);\nif (!parent || !Array.isArray(parent.subtasks)) {\n  throw new Error(`Parent ${parentId} missing or has no subtasks in tag '${tag}'. Run: task-master list`);\n}","typeGuard":"function parentWithSubtasks(tasks, parentId): parent is typeof tasks[number] & { subtasks: NonNullable<typeof tasks[number]['subtasks']> } {\n  const t = tasks.find((x) => x.id === parentId);\n  return t != null && Array.isArray(t.subtasks);\n}","tryCatchPattern":"try {\n  await tmCore.tasks.removeTask(tasksPath, [taskId]);\n} catch (err) {\n  if (err.message.includes('or its subtasks not found')) {\n    console.error('Parent task missing or has no subtasks — verify ID/tag with task-master list, or remove the main task directly.');\n  } else throw err;\n}","preventionTips":["Verify parent IDs in the active tag before dot-notation removal.","Pass --tag explicitly for non-default tags.","Use remove-task with a plain ID to delete the whole task instead.","Avoid hardcoded IDs in automation; resolve them at runtime."],"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"}