eyaltoledano/claude-task-master · error · Error

Tag "${oldName}" does not exist

Error message

Tag "${oldName}" does not exist

What it means

After loading the tagged data, renameTag() checks that the oldName key exists in rawData. If there is no tag with that name, this error is thrown. Tag names are exact string keys — matching is case-sensitive and no fuzzy lookup is performed.

Source

Thrown at scripts/modules/task-manager/tag-management.js:996

		const reservedNames = ['master', 'main', 'default'];
		if (reservedNames.includes(newName.toLowerCase())) {
			throw new Error(`"${newName}" is a reserved tag name`);
		}

		logFn.info(`Renaming tag from "${oldName}" to "${newName}"`);

		// Read current tasks data
		const data = readJSON(tasksPath, projectRoot);
		if (!data) {
			throw new Error(`Could not read tasks file at ${tasksPath}`);
		}

		// Use raw tagged data for tag operations
		const rawData = data._rawTaggedData || data;

		// Check if old tag exists
		if (!rawData[oldName]) {
			throw new Error(`Tag "${oldName}" does not exist`);
		}

		// Check if new tag name already exists
		if (rawData[newName]) {
			throw new Error(`Tag "${newName}" already exists`);
		}

		// Get current tag to check if we're renaming the active tag
		const currentTag = getCurrentTag(projectRoot);
		const isCurrentTag = currentTag === oldName;

		// Rename the tag by copying data and deleting old
		rawData[newName] = { ...rawData[oldName] };

		// Update metadata if it exists
		if (rawData[newName].metadata) {
			rawData[newName].metadata.renamed = {
				from: oldName,

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Run `task-master tags` (or inspect tasks.json) and use the exact current tag name
  2. Fix case-sensitivity: tag keys match exactly ('backlog' !== 'Backlog')
  3. Create the tag first with createTag if it genuinely does not exist
  4. Guard before calling: check the tag exists in the parsed tasks.json data

Example fix

// before
await renameTag(tasksPath, 'Backlog', 'todo');
// after
const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));
if (!data['backlog']) throw new Error('tag backlog not found');
await renameTag(tasksPath, 'backlog', 'todo');
Defensive patterns

Strategy: validation

Validate before calling

const data = JSON.parse(require('fs').readFileSync(tasksPath, 'utf8'));
if (!Object.prototype.hasOwnProperty.call(data, oldName)) {
  throw new Error(`Tag "${oldName}" does not exist. Available: ${Object.keys(data).join(', ')}`);
}

Type guard

function tagExists(tasksData, name) {
  return typeof name === 'string' && Object.prototype.hasOwnProperty.call(tasksData, name);
}

Try / catch

try {
  await renameTag(tasksPath, oldName, newName);
} catch (err) {
  if (err.message.includes('does not exist')) {
    console.error(`Unknown tag "${oldName}" — run 'task-master tags' to list valid names`);
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling renameTag with an oldName that was never created, was already renamed/deleted, or differs in case ('Backlog' vs 'backlog'); typos in the tag name.

Common situations: Renaming a tag twice (second call uses the pre-rename name); switching machines/branches where tasks.json has different tags; scripts hard-coding tag names that a teammate renamed; listing tags with task-master tags --list to discover valid names.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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