{"record":{"id":"83d5837d11c0f7cb","repo":"eyaltoledano/claude-task-master","slug":"subtask-subtaskid-not-found","errorCode":null,"errorMessage":"Subtask ${subtaskId} not found","messagePattern":"Subtask (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/remove-subtask.js","lineNumber":58,"sourceCode":"\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) {\n\t\t\tparentTask.subtasks = undefined;\n\t\t}\n\n\t\tlet convertedTask = null;\n\n\t\t// Convert the subtask to a standalone task if requested\n\t\tif (convertToTask) {\n\t\t\tlog('info', `Converting subtask ${subtaskId} to a standalone task...`);","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/remove-subtask.js#L40-L76","documentation":"The parent task exists and has subtasks, but no subtask inside it matches the parsed subtask ID number, so removeSubtask throws this error.","triggerScenarios":"Calling removeSubtask('5.9') where task 5 has subtasks but none with id 9 (e.g. only ids 1-3 exist).","commonSituations":"Guessing subtask indices instead of listing them, subtask already deleted, subtasks were renumbered after compaction/changes, wrong parent chosen so the subtask sits under a different parent.","solutions":["Run 'task-master show 5' to list the actual subtask IDs of the parent.","Correct the subtask portion of the dot-notation ID.","If the subtask is under a different parent, rebuild the ID as <correctParent>.<subtaskId>."],"exampleFix":"// before\ntask-master remove-subtask --i=5.9\n// after\ntask-master remove-subtask --i=5.3  // id confirmed via `task-master show 5`","handlingStrategy":"validation","validationCode":"const [p, s] = subtaskId.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} does not exist under task ${p}. Run: task-master show ${p}`);\n}","typeGuard":"function subtaskExists(parent, subId) {\n  return parent?.subtasks?.some((st) => st.id === subId) === true;\n}","tryCatchPattern":"try {\n  await tmCore.tasks.removeSubtask(tasksPath, subtaskId);\n} catch (err) {\n  if (err.message.includes('Subtask') && err.message.includes('not found')) {\n    console.error(`Subtask not found under parent. Verify with: task-master show ${subtaskId.split('.')[0]}`);\n  } else throw err;\n}","preventionTips":["Always list subtasks via 'task-master show <parent>' before removing.","Never guess subtask indices; they are not array positions after edits.","Re-check IDs after any renumbering or prior removals.","Coordinate with teammates to avoid stale IDs on shared tasks.json."],"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"}