{"record":{"id":"a68ebbc16280d639","repo":"eyaltoledano/claude-task-master","slug":"subtask-subtaskid-not-found-in-parent-task-pa-a68ebb","errorCode":null,"errorMessage":"Subtask ${subtaskId} not found in parent task ${parentTaskId}","messagePattern":"Subtask (.+?) not found in parent task (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/remove-task.js","lineNumber":81,"sourceCode":"\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\n\t\t\t\t\t};\n\t\t\t\t\tresults.removedTasks.push(removedSubtask);\n\n\t\t\t\t\t// Remove the subtask from the parent\n\t\t\t\t\tparentTask.subtasks.splice(subtaskIndex, 1);\n\n\t\t\t\t\tresults.messages.push(\n\t\t\t\t\t\t`Successfully removed subtask ${taskId} from tag '${tag}'`\n\t\t\t\t\t);\n\t\t\t\t}","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/remove-task.js#L63-L99","documentation":"After locating the parent task and its subtasks array, removeTask searches for the specific subtask ID. If no subtask in the parent matches the parsed ID, this error is thrown before removal proceeds.","triggerScenarios":"Calling removeTask('7.9') where task 7 exists with subtasks but none has id 9 (ids may only be 1-4, or the subtask was already removed).","commonSituations":"Stale or guessed subtask indices, subtasks renumbered after other removals, wrong parent supplied so the subtask is under a different task, concurrent edits by teammates/tools.","solutions":["Run 'task-master show 7' to list valid subtask IDs and correct the ID.","Verify the subtask wasn't already removed (list again before retrying).","Target the correct parent: rebuild the ID as <correctParent>.<subtaskId>."],"exampleFix":"// before\ntask-master remove-task --i=7.9\n// after\ntask-master remove-task --i=7.2  // confirmed via `task-master show 7`","handlingStrategy":"validation","validationCode":"const [p, s] = taskId.split('.').map(Number);\nconst parent = tasks.find((t) => t.id === p);\nif (!parent?.subtasks?.some((st) => st.id === s)) {\n  throw new Error(`Subtask ${s} not under task ${p}. Confirm with: task-master show ${p}`);\n}","typeGuard":"function subtaskInParent(parent, subId): boolean {\n  return parent?.subtasks?.some((st) => st.id === subId) === true;\n}","tryCatchPattern":"try {\n  await tmCore.tasks.removeTask(tasksPath, [`${parentId}.${subtaskId}`]);\n} catch (err) {\n  if (err.message.includes('not found in parent task')) {\n    console.error(`Subtask ${subtaskId} not under parent ${parentId}. List actual subtasks with: task-master show ${parentId}`);\n  } else throw err;\n}","preventionTips":["Show the parent task to enumerate real subtask IDs before removal.","Treat removal as idempotent; skip if the subtask is already gone.","Re-derive IDs after any prior removals (renumbering is possible).","Check under the correct tag before concluding an ID is wrong."],"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"}