eyaltoledano/claude-task-master · error · Error

Target tag name is required and must be a string

Error message

Target tag name is required and must be a string

What it means

copyTag() requires the target tag name to be a non-empty string. This error is thrown when targetName is missing, null, undefined, empty, or not a string. The target is the new tag key that will receive a deep copy of the source tag's tasks.

Source

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

	const { mcpLog, projectRoot } = context;
	const { description } = options;

	// Create a consistent logFn object regardless of context
	const logFn = mcpLog || {
		info: (...args) => log('info', ...args),
		warn: (...args) => log('warn', ...args),
		error: (...args) => log('error', ...args),
		debug: (...args) => log('debug', ...args),
		success: (...args) => log('success', ...args)
	};

	try {
		// Validate parameters
		if (!sourceName || typeof sourceName !== 'string') {
			throw new Error('Source tag name is required and must be a string');
		}
		if (!targetName || typeof targetName !== 'string') {
			throw new Error('Target tag name is required and must be a string');
		}

		// Validate target tag name format
		if (!/^[a-zA-Z0-9_-]+$/.test(targetName)) {
			throw new Error(
				'Target tag name can only contain letters, numbers, hyphens, and underscores'
			);
		}

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

		logFn.info(`Copying tag from "${sourceName}" to "${targetName}"`);

		// Read current tasks data

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Pass a non-empty string as the third argument (targetName) to copyTag
  2. Validate targetName before calling: if (!targetName || typeof targetName !== 'string') throw ...
  3. Ensure downstream code also satisfies the later format/reserved-name checks (alphanumeric, hyphen, underscore; not master/main/default)

Example fix

// before
await copyTag(tasksPath, 'master', opts.backupName); // opts.backupName undefined
// after
const target = opts.backupName || `backup-${new Date().toISOString().slice(0, 10)}`;
await copyTag(tasksPath, 'master', target);
Defensive patterns

Strategy: validation

Validate before calling

if (!targetName || typeof targetName !== 'string') {
  throw new Error('copyTag: targetName must be a non-empty string');
}

Type guard

function isNonEmptyString(v) {
  return typeof v === 'string' && v.trim().length > 0;
}

Try / catch

try {
  await copyTag(tasksPath, sourceName, targetName);
} catch (err) {
  if (err.message.includes('Target tag name is required')) {
    console.error('Missing or invalid target tag name — provide one explicitly');
    return;
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling copyTag(tasksPath, sourceName, targetName) with targetName omitted, empty string, or a non-string value; prompt cancellations forwarding undefined; argument-order mistakes.

Common situations: Automated backup scripts where the target-name variable was never set; CLI invocations missing the second positional argument; config-driven workflows with a missing targetName field.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — 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/33b713a6b0b70314. Report an issue: GitHub.