{"record":{"id":"9a36c6ff0f987132","repo":"eyaltoledano/claude-task-master","slug":"parent-task-with-id-parentid-not-found","errorCode":null,"errorMessage":"Parent task with ID ${parentId} not found","messagePattern":"Parent task with ID (.+?) not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/remove-subtask.js","lineNumber":45,"sourceCode":"\t\tif (!data || !data.tasks) {\n\t\t\tthrow new Error(`Invalid or missing tasks file at ${tasksPath}`);\n\t\t}\n\n\t\t// Parse the subtask ID (format: \"parentId.subtaskId\")\n\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","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/remove-subtask.js#L27-L63","documentation":"After parsing the parent ID from the dot-notation subtask ID, removeSubtask searches data.tasks for a task with a matching id. If none is found, the parent referenced by the subtask ID does not exist, so this error is thrown.","triggerScenarios":"Calling removeSubtask('99.2') where no task with id 99 exists in the current tag's tasks array, or the ID exists only in a different tag.","commonSituations":"Typo in the parent ID, referencing a task that was already removed, operating under the wrong tag so the parent isn't visible, stale IDs from a shared/edited tasks.json.","solutions":["Run 'task-master list' to confirm the parent task ID in the active tag.","Add --tag (or switch the active tag) to the tag containing the parent task.","Correct the typo in the parent portion of the dot-notation ID."],"exampleFix":"// before\ntask-master remove-subtask --i=99.2\n// after\ntask-master remove-subtask --i=5.2 --tag=feature-x","handlingStrategy":"validation","validationCode":"const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));\nconst parentId = parseInt(subtaskId.split('.')[0], 10);\nconst parent = (data[tag]?.tasks ?? data.tasks ?? []).find((t) => t.id === parentId);\nif (!parent) throw new Error(`Parent task ${parentId} not found in tag '${tag}'; run task-master list`);","typeGuard":"function parentExists(tasks, parentId) {\n  return tasks.some((t) => t.id === parentId);\n}","tryCatchPattern":"try {\n  await tmCore.tasks.removeSubtask(tasksPath, subtaskId);\n} catch (err) {\n  if (err.message.includes('Parent task with ID')) {\n    console.error('Parent task not found — verify the ID under the active tag with task-master list.');\n  } else throw err;\n}","preventionTips":["List tasks before mutating to confirm IDs.","Pass --tag explicitly when working outside the default tag.","Avoid hardcoding task IDs in scripts; read them from list output.","Refresh your view after teammates/tools modify 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"}