eyaltoledano/claude-task-master · error · Error

Invalid tasks file or tag "${tag}" not found at ${tasksPath}

Error message

Invalid tasks file or tag "${tag}" not found at ${tasksPath}

What it means

After loading the tasks file, setTaskStatus verifies that the resolved raw data actually contains an entry for the given tag with a tasks array. If the file is unreadable/corrupt or the tag key is missing, it throws this error. It protects against operating on a nonexistent tag context.

Source

Thrown at scripts/modules/task-manager/set-task-status.js:67

					borderStyle: 'round'
				})
			);
		}

		log('info', `Reading tasks from ${tasksPath}...`);

		// Read the raw data without tag resolution to preserve tagged structure
		let rawData = readJSON(tasksPath, projectRoot, tag); // No tag parameter

		// Handle the case where readJSON returns resolved data with _rawTaggedData
		if (rawData && rawData._rawTaggedData) {
			// Use the raw tagged data and discard the resolved view
			rawData = rawData._rawTaggedData;
		}

		// Ensure the tag exists in the raw data
		if (!rawData || !rawData[tag] || !Array.isArray(rawData[tag].tasks)) {
			throw new Error(
				`Invalid tasks file or tag "${tag}" not found at ${tasksPath}`
			);
		}

		// Get the tasks for the current tag
		const data = {
			tasks: rawData[tag].tasks,
			tag,
			_rawTaggedData: rawData
		};

		if (!data || !data.tasks) {
			throw new Error(`No valid tasks found in ${tasksPath}`);
		}

		// Handle multiple task IDs (comma-separated)
		const taskIds = taskIdInput.split(',').map((id) => id.trim());
		const updatedTasks = [];

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Run 'task-master tags' to list existing tags and use one that exists
  2. Create the tag first with 'task-master add-tag <name>'
  3. Verify the tasksPath points to a valid .taskmaster/tasks/tasks.json containing the tag key
  4. Omit the tag option to use the current/default tag

Example fix

// before
await setTaskStatus(tasksPath, '1', 'done', { tag: 'release' }); // tag absent
// after
await setTaskStatus(tasksPath, '1', 'done'); // uses current tag
Defensive patterns

Strategy: validation

Validate before calling

const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));
if (tag && !(tag in data)) {
  throw new Error(`Tag '${tag}' not found. Available: ${Object.keys(data).filter((k) => data[k]?.tasks).join(', ')}`);
}

Type guard

function tagExists(rawData, tag) {
  return Boolean(rawData && rawData[tag] && Array.isArray(rawData[tag].tasks));
}

Try / catch

try {
  await setTaskStatus(tasksPath, id, status, { tag });
} catch (err) {
  if (err.message.includes('not found at')) {
    console.error(`Tag '${tag}' missing — run 'task-master tags' to list, or 'add-tag ${tag}' to create.`);
  } else throw err;
}

Prevention

When it happens

Trigger: Calling setTaskStatus with options.tag set to a tag that was never created, passing a tasksPath pointing to a malformed/empty JSON file, or reading raw data where the tag array was removed by hand editing.

Common situations: Typos in --tag ('feature-auth' vs 'featureauth'); fresh repos where only 'master' exists; hand-edited tasks.json dropping a tag; wrong tasksPath passed in scripts.

Related errors


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