eyaltoledano/claude-task-master · error

Parent task with ID ${parentId} not found

Error message

Parent task with ID ${parentId} not found

What it means

After parsing the parent ID from the dot-notation subtask ID, removeSubtask searches data.tasks for a task with a matching id. If none is found, the parent referenced by the subtask ID does not exist, so this error is thrown.

Source

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

		if (!data || !data.tasks) {
			throw new Error(`Invalid or missing tasks file at ${tasksPath}`);
		}

		// Parse the subtask ID (format: "parentId.subtaskId")
		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] };

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Run 'task-master list' to confirm the parent task ID in the active tag.
  2. Add --tag (or switch the active tag) to the tag containing the parent task.
  3. Correct the typo in the parent portion of the dot-notation ID.

Example fix

// before
task-master remove-subtask --i=99.2
// after
task-master remove-subtask --i=5.2 --tag=feature-x
Defensive patterns

Strategy: validation

Validate before calling

const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));
const parentId = parseInt(subtaskId.split('.')[0], 10);
const parent = (data[tag]?.tasks ?? data.tasks ?? []).find((t) => t.id === parentId);
if (!parent) throw new Error(`Parent task ${parentId} not found in tag '${tag}'; run task-master list`);

Type guard

function parentExists(tasks, parentId) {
  return tasks.some((t) => t.id === parentId);
}

Try / catch

try {
  await tmCore.tasks.removeSubtask(tasksPath, subtaskId);
} catch (err) {
  if (err.message.includes('Parent task with ID')) {
    console.error('Parent task not found — verify the ID under the active tag with task-master list.');
  } else throw err;
}

Prevention

When it happens

Trigger: Calling removeSubtask('99.2') where no task with id 99 exists in the current tag's tasks array, or the ID exists only in a different tag.

Common situations: Typo in the parent ID, referencing a task that was already removed, operating under the wrong tag so the parent isn't visible, stale IDs from a shared/edited tasks.json.

Related errors


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