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

  1. Run 'task-master show 5' to list the actual subtask IDs of the parent.
  2. Correct the subtask portion of the dot-notation ID.
  3. 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

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


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/83d5837d11c0f7cb. Report an issue: GitHub.