eyaltoledano/claude-task-master · error
Subtask ${subtaskId} not found
Error message
Subtask ${subtaskId} not found What it means
The parent task exists and has subtasks, but no subtask inside it matches the parsed subtask ID number, so removeSubtask throws this error.
Source
Thrown at scripts/modules/task-manager/remove-subtask.js:58
const subtaskIdNum = parseInt(subtaskIdStr, 10);
// Find the parent task
const parentTask = data.tasks.find((t) => t.id === parentId);
if (!parentTask) {
throw new Error(`Parent task with ID ${parentId} not found`);
}
// Check if parent has subtasks
if (!parentTask.subtasks || parentTask.subtasks.length === 0) {
throw new Error(`Parent task ${parentId} has no subtasks`);
}
// Find the subtask to remove
const subtaskIndex = parentTask.subtasks.findIndex(
(st) => st.id === subtaskIdNum
);
if (subtaskIndex === -1) {
throw new Error(`Subtask ${subtaskId} not found`);
}
// Get a copy of the subtask before removing it
const removedSubtask = { ...parentTask.subtasks[subtaskIndex] };
// Remove the subtask from the parent
parentTask.subtasks.splice(subtaskIndex, 1);
// If parent has no more subtasks, remove the subtasks array
if (parentTask.subtasks.length === 0) {
parentTask.subtasks = undefined;
}
let convertedTask = null;
// Convert the subtask to a standalone task if requested
if (convertToTask) {
log('info', `Converting subtask ${subtaskId} to a standalone task...`);View on GitHub (pinned to c0c98d367c)
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>.
Example fix
// before task-master remove-subtask --i=5.9 // after task-master remove-subtask --i=5.3 // id confirmed via `task-master show 5`
Defensive patterns
Strategy: validation
Validate before calling
const [p, s] = subtaskId.split('.').map(Number);
const parent = tasks.find((t) => t.id === p);
if (!parent?.subtasks?.some((st) => st.id === s)) {
throw new Error(`Subtask ${s} does not exist under task ${p}. Run: task-master show ${p}`);
} Type guard
function subtaskExists(parent, subId) {
return parent?.subtasks?.some((st) => st.id === subId) === true;
} Try / catch
try {
await tmCore.tasks.removeSubtask(tasksPath, subtaskId);
} catch (err) {
if (err.message.includes('Subtask') && err.message.includes('not found')) {
console.error(`Subtask not found under parent. Verify with: task-master show ${subtaskId.split('.')[0]}`);
} else throw err;
} Prevention
- 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.
When it happens
Trigger: Calling removeSubtask('5.9') where task 5 has subtasks but none with id 9 (e.g. only ids 1-3 exist).
Common situations: 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.
Related errors
- Parent task with ID ${parentId} not found
- Parent task ${parentId} has no subtasks
- Parent task ${parentTaskId} or its subtasks not found for su
- 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/83d5837d11c0f7cb.
Report an issue: GitHub.