eyaltoledano/claude-task-master · error

Task with ID ${numericTaskId} not found.

Error message

Task with ID ${numericTaskId} not found.

What it means

updateTaskById() reads tasks.json, converts the validated numeric ID, and searches data.tasks with findIndex. This error is thrown when no task with that integer id exists in the (tag-scoped) tasks file, after logging the same message via report().

Source

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

		// --- End Input Validations ---

		// --- Task Loading and Status Check (Keep existing) ---
		const data = readJSON(tasksPath, projectRoot, tag);
		if (!data || !data.tasks)
			throw new Error(`No valid tasks found in ${tasksPath}.`);
		// File storage requires a strict numeric task ID
		const idStr = String(taskId).trim();
		if (!/^\d+$/.test(idStr)) {
			throw new Error(
				'For file storage, taskId must be a positive integer. ' +
					'Use update-subtask-by-id for IDs like "1.2", or run in API storage for display IDs (e.g., "HAM-123").'
			);
		}
		const numericTaskId = Number(idStr);
		const taskIndex = data.tasks.findIndex((task) => task.id === numericTaskId);
		if (taskIndex === -1) {
			report('error', `Task with ID ${numericTaskId} not found`);
			throw new Error(`Task with ID ${numericTaskId} not found.`);
		}
		const taskToUpdate = data.tasks[taskIndex];
		if (taskToUpdate.status === 'done' || taskToUpdate.status === 'completed') {
			report(
				'warn',
				`Task ${taskId} is already marked as done and cannot be updated`
			);

			// Only show warning box for text output (CLI)
			if (outputFormat === 'text') {
				console.log(
					boxen(
						chalk.yellow(
							`Task ${taskId} is already marked as ${taskToUpdate.status} and cannot be updated.`
						) +
							'\n\n' +
							chalk.white(
								'Completed tasks are locked to maintain consistency. To modify a completed task, you must first:'

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Run 'task-master list' (for the active tag) to confirm the task ID exists
  2. Check the active tag/context — switch tags or pass the correct one so the right tasks file is searched
  3. Update hardcoded IDs in scripts to current ones, or look the ID up dynamically before updating
  4. Restore the missing task from backup/git if it was deleted by mistake

Example fix

// before
await updateTaskById(99, prompt); // may not exist
// after
const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));
if (data.tasks.some(t => t.id === 99)) {
  await updateTaskById(99, prompt);
} else {
  console.error('Task 99 not found in current tag');
}
Defensive patterns

Strategy: validation

Validate before calling

const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));
const exists = Array.isArray(data.tasks) && data.tasks.some(t => t.id === numericTaskId);
if (!exists) throw new Error(`Task ${numericTaskId} not found in ${tasksPath}`);

Type guard

function taskExists(tasks, id) {
  return Array.isArray(tasks) && tasks.some(t => t.id === id);
}

Try / catch

try {
  await updateTaskById(numericTaskId, prompt);
} catch (err) {
  if (err.message.includes('not found') && !err.message.includes('Subtask')) {
    console.error(`Task ${numericTaskId} missing; run 'task-master list' for current IDs`);
  } else throw err;
}

Prevention

When it happens

Trigger: Calling updateTaskById(99, prompt) when tasks.json only has IDs 1-20; querying the wrong tag whose file lacks that ID; the task was deleted or renumbered by another command between listing and updating.

Common situations: Hardcoded IDs in scripts after the task list changed; forgetting that IDs are per-tag, so master IDs differ from a feature tag's; stale automation reading an old snapshot of tasks.json.

Related errors


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