eyaltoledano/claude-task-master · error
Subtask ${subtaskId} not found in parent task ${parentTaskId
Error message
Subtask ${subtaskId} not found in parent task ${parentTaskId} What it means
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.
Source
Thrown at scripts/modules/task-manager/remove-task.js:81
if (typeof taskId === 'string' && taskId.includes('.')) {
const [parentTaskId, subtaskId] = taskId
.split('.')
.map((id) => parseInt(id, 10));
// Find the parent task
const parentTask = tasks.find((t) => t.id === parentTaskId);
if (!parentTask || !parentTask.subtasks) {
throw new Error(
`Parent task ${parentTaskId} or its subtasks not found for subtask ${taskId}`
);
}
// Find the subtask to remove
const subtaskIndex = parentTask.subtasks.findIndex(
(st) => st.id === subtaskId
);
if (subtaskIndex === -1) {
throw new Error(
`Subtask ${subtaskId} not found in parent task ${parentTaskId}`
);
}
// Store the subtask info before removal
const removedSubtask = {
...parentTask.subtasks[subtaskIndex],
parentTaskId: parentTaskId
};
results.removedTasks.push(removedSubtask);
// Remove the subtask from the parent
parentTask.subtasks.splice(subtaskIndex, 1);
results.messages.push(
`Successfully removed subtask ${taskId} from tag '${tag}'`
);
}View on GitHub (pinned to c0c98d367c)
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>.
Example fix
// before task-master remove-task --i=7.9 // after task-master remove-task --i=7.2 // confirmed via `task-master show 7`
Defensive patterns
Strategy: validation
Validate before calling
const [p, s] = taskId.split('.').map(Number);
const parent = tasks.find((t) => t.id === p);
if (!parent?.subtasks?.some((st) => st.id === s)) {
throw new Error(`Subtask ${s} not under task ${p}. Confirm with: task-master show ${p}`);
} Type guard
function subtaskInParent(parent, subId): boolean {
return parent?.subtasks?.some((st) => st.id === subId) === true;
} Try / catch
try {
await tmCore.tasks.removeTask(tasksPath, [`${parentId}.${subtaskId}`]);
} catch (err) {
if (err.message.includes('not found in parent task')) {
console.error(`Subtask ${subtaskId} not under parent ${parentId}. List actual subtasks with: task-master show ${parentId}`);
} else throw err;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Parent task with ID ${parentId} not found
- Parent task ${parentId} has no subtasks
- Subtask ${subtaskId} not found
- Parent task ${parentTaskId} or its subtasks not found for su
- PARENT_TASK_NOT_FOUND
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/a68ebbc16280d639.
Report an issue: GitHub.