eyaltoledano/claude-task-master · error

Subtask with ID ${subtaskId} not found. Please verify the su

Error message

Subtask with ID ${subtaskId} not found. Please verify the subtask ID and try again.

What it means

updateSubtaskById() parses the parent.subtask ID and searches the parent's subtasks array with findIndex. This error is thrown when the parent task and its subtasks exist but no subtask matches the given subtask number, meaning the referenced subtask does not exist.

Source

Thrown at scripts/modules/task-manager/update-subtask-by-id.js:170

			);
		}

		const parentTask = data.tasks.find((task) => task.id === parentId);
		if (!parentTask) {
			throw new Error(
				`Parent task with ID ${parentId} not found. Please verify the task ID and try again.`
			);
		}

		if (!parentTask.subtasks || !Array.isArray(parentTask.subtasks)) {
			throw new Error(`Parent task ${parentId} has no subtasks.`);
		}

		const subtaskIndex = parentTask.subtasks.findIndex(
			(st) => st.id === subtaskIdNum
		);
		if (subtaskIndex === -1) {
			throw new Error(
				`Subtask with ID ${subtaskId} not found. Please verify the subtask ID and try again.`
			);
		}

		const subtask = parentTask.subtasks[subtaskIndex];

		// --- Metadata-Only Update (Fast Path) ---
		// If only metadata is provided (no prompt), skip AI and just update metadata
		if (metadata && (!prompt || prompt.trim() === '')) {
			report('info', `Metadata-only update for subtask ${subtaskId}`);
			// Merge new metadata with existing
			subtask.metadata = {
				...(subtask.metadata || {}),
				...metadata
			};
			parentTask.subtasks[subtaskIndex] = subtask;
			writeJSON(tasksPath, data, projectRoot, tag);
			report(

View on GitHub (pinned to c0c98d367c)

Solutions

  1. List the parent task's subtasks ('task-master list --with-subtasks' or read tasks.json) and use a valid subtask number
  2. Verify you are using the correct parent ID in parent.subtask form (5.2, not 2 or 7)
  3. Re-fetch the latest tasks.json if subtasks were recently modified by another process
  4. If the subtask should exist, restore it or recreate it before updating

Example fix

// before
await updateSubtaskById('5.7', prompt); // subtask 7 may not exist
// after
const parent = tasks.find(t => t.id === 5);
const max = parent?.subtasks?.length ?? 0;
if (subtaskNum <= max) await updateSubtaskById(`5.${subtaskNum}`, prompt);
Defensive patterns

Strategy: validation

Validate before calling

const [pid, sid] = subtaskId.split('.').map(Number);
const parent = data.tasks.find(t => t.id === pid);
const exists = parent?.subtasks?.some(st => st.id === sid);
if (!exists) throw new Error(`Subtask ${subtaskId} does not exist`);

Type guard

function subtaskExists(tasks, parentId, subtaskId) {
  const parent = tasks.find(t => t.id === parentId);
  return !!parent?.subtasks?.some(st => st.id === subtaskId);
}

Try / catch

try {
  await updateSubtaskById(subtaskId, prompt);
} catch (err) {
  if (err.message.includes('Subtask with ID') && err.message.includes('not found')) {
    console.error(`Invalid subtask ${subtaskId}; list the parent task to get valid IDs`);
  } else throw err;
}

Prevention

When it happens

Trigger: Calling updateSubtaskById with e.g. '5.7' when task 5 only has subtasks 1-3; passing the full string '5.7' after the parent lookup succeeded but st.id === subtaskIdNum finds no match.

Common situations: Off-by-one or out-of-range subtask numbers; stale IDs after subtasks were removed/renumbered; confusing global subtask numbering with per-parent numbering; reading IDs from an outdated task list.

Related errors


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