{"record":{"id":"33b713a6b0b70314","repo":"eyaltoledano/claude-task-master","slug":"target-tag-name-is-required-and-must-be-a-string","errorCode":null,"errorMessage":"Target tag name is required and must be a string","messagePattern":"Target tag name is required and must be a string","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/tag-management.js","lineNumber":1128,"sourceCode":"\tconst { mcpLog, projectRoot } = context;\n\tconst { description } = options;\n\n\t// Create a consistent logFn object regardless of context\n\tconst logFn = mcpLog || {\n\t\tinfo: (...args) => log('info', ...args),\n\t\twarn: (...args) => log('warn', ...args),\n\t\terror: (...args) => log('error', ...args),\n\t\tdebug: (...args) => log('debug', ...args),\n\t\tsuccess: (...args) => log('success', ...args)\n\t};\n\n\ttry {\n\t\t// Validate parameters\n\t\tif (!sourceName || typeof sourceName !== 'string') {\n\t\t\tthrow new Error('Source tag name is required and must be a string');\n\t\t}\n\t\tif (!targetName || typeof targetName !== 'string') {\n\t\t\tthrow new Error('Target tag name is required and must be a string');\n\t\t}\n\n\t\t// Validate target tag name format\n\t\tif (!/^[a-zA-Z0-9_-]+$/.test(targetName)) {\n\t\t\tthrow new Error(\n\t\t\t\t'Target tag name can only contain letters, numbers, hyphens, and underscores'\n\t\t\t);\n\t\t}\n\n\t\t// Reserved tag names\n\t\tconst reservedNames = ['master', 'main', 'default'];\n\t\tif (reservedNames.includes(targetName.toLowerCase())) {\n\t\t\tthrow new Error(`\"${targetName}\" is a reserved tag name`);\n\t\t}\n\n\t\tlogFn.info(`Copying tag from \"${sourceName}\" to \"${targetName}\"`);\n\n\t\t// Read current tasks data","sourceCodeStart":1110,"sourceCodeEnd":1146,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/tag-management.js#L1110-L1146","documentation":"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.","triggerScenarios":"Calling copyTag(tasksPath, sourceName, targetName) with targetName omitted, empty string, or a non-string value; prompt cancellations forwarding undefined; argument-order mistakes.","commonSituations":"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.","solutions":["Pass a non-empty string as the third argument (targetName) to copyTag","Validate targetName before calling: if (!targetName || typeof targetName !== 'string') throw ...","Ensure downstream code also satisfies the later format/reserved-name checks (alphanumeric, hyphen, underscore; not master/main/default)"],"exampleFix":"// before\nawait copyTag(tasksPath, 'master', opts.backupName); // opts.backupName undefined\n// after\nconst target = opts.backupName || `backup-${new Date().toISOString().slice(0, 10)}`;\nawait copyTag(tasksPath, 'master', target);","handlingStrategy":"validation","validationCode":"if (!targetName || typeof targetName !== 'string') {\n  throw new Error('copyTag: targetName must be a non-empty string');\n}","typeGuard":"function isNonEmptyString(v) {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  await copyTag(tasksPath, sourceName, targetName);\n} catch (err) {\n  if (err.message.includes('Target tag name is required')) {\n    console.error('Missing or invalid target tag name — provide one explicitly');\n    return;\n  }\n  throw err;\n}","preventionTips":["Provide an explicit target name; generate dated defaults (backup-YYYY-MM-DD) for scripts","Ensure prompt cancellations don't forward undefined as the target","Pre-validate the full name rules: non-empty string, /^[a-zA-Z0-9_-]+$/, not reserved"],"tags":["validation","parameter-validation","tag-management"],"backgroundTag":"missing-required-argument","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}