eyaltoledano/claude-task-master · error

Tag "${targetTag}" not found.

Error message

Tag "${targetTag}" not found.

What it means

addTask writes new tasks into a specific tag's task list within the multi-tag tasks file; this error is thrown when the target tag key does not exist in the raw data. Tags act as isolated task collections, so writing to a nonexistent tag is refused instead of silently creating it.

Source

Thrown at scripts/modules/task-manager/add-task.js:268

			// Do not write the file here; it will be written later with the new task.

			// Perform complete migration (config.json, state.json)
			performCompleteTagMigration(tasksPath);
			markMigrationForNotice(tasksPath);

			report('Successfully migrated to tagged format.', 'success');
		}

		// Use the provided tag, or the current active tag, or default to 'master'
		const targetTag = tag;

		// Ensure the target tag exists
		if (!rawData[targetTag]) {
			report(
				`Tag "${targetTag}" does not exist. Please create it first using the 'add-tag' command.`,
				'error'
			);
			throw new Error(`Tag "${targetTag}" not found.`);
		}

		// Ensure the target tag has a tasks array and metadata object
		if (!rawData[targetTag].tasks) {
			rawData[targetTag].tasks = [];
		}
		if (!rawData[targetTag].metadata) {
			rawData[targetTag].metadata = {
				created: new Date().toISOString(),
				updated: new Date().toISOString(),
				description: ``
			};
		}

		// Get a flat list of ALL tasks across ALL tags to validate dependencies
		const allTasks = getAllTasks(rawData);

		// Find the highest task ID *within the target tag* to determine the next ID

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Create the tag first: run 'task-master add-tag <name>' (or the equivalent API).
  2. Verify the exact tag name in your tasks file — check for typos or case differences.
  3. List existing tags to confirm which are available.
  4. Re-run addTask with the correct existing tag.

Example fix

// before
await addTask({ prompt: 'New task', tag: 'release-2' }); // tag missing
// after
await tmCore.tags.create('release-2'); // or: task-master add-tag release-2
await addTask({ prompt: 'New task', tag: 'release-2' });
Defensive patterns

Strategy: validation

Validate before calling

const rawData = readJSON(tasksPath, projectRoot);
if (!rawData[targetTag]) {
  throw new Error(`Tag "${targetTag}" missing — run add-tag first`);
}

Type guard

function tagExists(rawData, tag) {
  return Object.prototype.hasOwnProperty.call(rawData ?? {}, tag);
}

Try / catch

try {
  await addTask({ prompt, tag: targetTag });
} catch (err) {
  if (err.message.startsWith('Tag "') && err.message.includes('not found')) {
    const tag = err.message.match(/Tag "(.+)" not found/)?.[1];
    // create the tag, then retry once
  } else throw err;
}

Prevention

When it happens

Trigger: Calling addTask with a targetTag that has never been created, e.g. after switching tags or typos in --tag flags.

Common situations: Users forgetting to run 'add-tag' before adding tasks to a new tag, mistyping tag names, or referencing tags that exist only in another environment's tasks file.

Related errors


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