eyaltoledano/claude-task-master · error
Parent task ${parentTaskId} or its subtasks not found for su
Error message
Parent task ${parentTaskId} or its subtasks not found for subtask ${taskId} What it means
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.
Source
Thrown at scripts/modules/task-manager/remove-task.js:71
// Check if the task ID exists *before* attempting removal
if (!taskExists(tasks, taskId)) {
const errorMsg = `Task with ID ${taskId} in tag '${tag}' not found or already removed.`;
results.errors.push(errorMsg);
results.success = false; // Mark overall success as false if any error occurs
continue; // Skip to the next ID
}
try {
// Handle subtask removal (e.g., '5.2')
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: parentTaskIdView on GitHub (pinned to c0c98d367c)
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.
Example fix
// before task-master remove-task --i=12.3 // parent 12 missing // after task-master remove-task --i=7.3 --tag=master // corrected ID/tag
Defensive patterns
Strategy: validation
Validate before calling
const [parentIdStr] = taskId.split('.');
const parentId = parseInt(parentIdStr, 10);
const tasks = data[tag]?.tasks ?? [];
const parent = tasks.find((t) => t.id === parentId);
if (!parent || !Array.isArray(parent.subtasks)) {
throw new Error(`Parent ${parentId} missing or has no subtasks in tag '${tag}'. Run: task-master list`);
} Type guard
function parentWithSubtasks(tasks, parentId): parent is typeof tasks[number] & { subtasks: NonNullable<typeof tasks[number]['subtasks']> } {
const t = tasks.find((x) => x.id === parentId);
return t != null && Array.isArray(t.subtasks);
} Try / catch
try {
await tmCore.tasks.removeTask(tasksPath, [taskId]);
} catch (err) {
if (err.message.includes('or its subtasks not found')) {
console.error('Parent task missing or has no subtasks — verify ID/tag with task-master list, or remove the main task directly.');
} else throw err;
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Parent task with ID ${parentId} not found
- Parent task ${parentId} has no subtasks
- Subtask ${subtaskId} not found
- Subtask ${subtaskId} not found in parent task ${parentTaskId
- PARENT_TASK_NOT_FOUND
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/09dd8d16b977ba4e.
Report an issue: GitHub.