eyaltoledano/claude-task-master · error

Parent task ${parentId} has no subtasks

Error message

Parent task ${parentId} has no subtasks

What it means

removeSubtask requires the located parent task to actually contain subtasks. If the parent's subtasks array is missing or empty, there is nothing to remove, so this error is thrown.

Source

Thrown at scripts/modules/task-manager/remove-subtask.js:50

		if (!subtaskId.includes('.')) {
			throw new Error(
				`Invalid subtask ID format: ${subtaskId}. Expected format: "parentId.subtaskId"`
			);
		}

		const [parentIdStr, subtaskIdStr] = subtaskId.split('.');
		const parentId = parseInt(parentIdStr, 10);
		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) {

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Run 'task-master list --with-subtasks' (or show the parent) to confirm subtasks exist.
  2. If the subtask was already removed, no action is needed — treat as no-op.
  3. Re-run expand or add-subtask to create subtasks before attempting removal.
  4. Verify you are on the correct tag where the subtasks live.

Example fix

// before
task-master remove-subtask --i=3.1  // task 3 has no subtasks
// after
task-master add-subtask --parent=3 --title="Fix bug" && task-master remove-subtask --i=3.1
Defensive patterns

Strategy: validation

Validate before calling

const parent = tasks.find((t) => t.id === parentId);
const subId = parseInt(subtaskId.split('.')[1], 10);
const hasSub = Array.isArray(parent?.subtasks) && parent.subtasks.some((s) => s.id === subId);
if (!hasSub) throw new Error(`Task ${parentId} has no subtask ${subId}; nothing to remove`);

Type guard

function hasSubtasks(t) {
  return Array.isArray(t?.subtasks) && t.subtasks.length > 0;
}

Try / catch

try {
  await tmCore.tasks.removeSubtask(tasksPath, subtaskId);
} catch (err) {
  if (err.message.includes('has no subtasks')) {
    console.error('Parent has no subtasks — the subtask may already be removed; treat as no-op or create subtasks first.');
  } else throw err;
}

Prevention

When it happens

Trigger: Calling removeSubtask('3.1') where task 3 exists but has no subtasks (subtasks array absent or zero-length).

Common situations: The subtask was already removed in a previous run, expanding task 3 failed so subtasks were never created, confusing the parent's own ID with a subtask ID, another teammate/tool flattened the subtasks.

Related errors


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