{"record":{"id":"70b25a2449307a35","repo":"eyaltoledano/claude-task-master","slug":"new-tag-name-is-required-and-must-be-a-string","errorCode":null,"errorMessage":"New tag name is required and must be a string","messagePattern":"New 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":962,"sourceCode":") {\n\tconst { mcpLog, projectRoot } = context;\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 (!oldName || typeof oldName !== 'string') {\n\t\t\tthrow new Error('Old tag name is required and must be a string');\n\t\t}\n\t\tif (!newName || typeof newName !== 'string') {\n\t\t\tthrow new Error('New tag name is required and must be a string');\n\t\t}\n\n\t\t// Validate new tag name format\n\t\tif (!/^[a-zA-Z0-9_-]+$/.test(newName)) {\n\t\t\tthrow new Error(\n\t\t\t\t'New tag name can only contain letters, numbers, hyphens, and underscores'\n\t\t\t);\n\t\t}\n\n\t\t// Prevent renaming master tag\n\t\tif (oldName === 'master') {\n\t\t\tthrow new Error('Cannot rename the \"master\" tag');\n\t\t}\n\n\t\t// Reserved tag names\n\t\tconst reservedNames = ['master', 'main', 'default'];\n\t\tif (reservedNames.includes(newName.toLowerCase())) {\n\t\t\tthrow new Error(`\"${newName}\" is a reserved tag name`);","sourceCodeStart":944,"sourceCodeEnd":980,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/tag-management.js#L944-L980","documentation":"renameTag() requires the new tag name to be a non-empty string. This error is thrown when newName is missing, null, undefined, empty, or a non-string type. It ensures the new tag key written into the tagged tasks data is a valid string.","triggerScenarios":"Calling renameTag(tasksPath, oldName, newName) with newName omitted, empty string, null, or a non-string value such as a number or object.","commonSituations":"Prompt/CLI flows where the user cancelled the name prompt and undefined was forwarded; JSON config files missing the new-name field; programmatic callers mixing up argument order so the value lands elsewhere.","solutions":["Pass a non-empty string as the third argument (newName) to renameTag","Validate newName before calling: if (!newName || typeof newName !== 'string') throw ...","Fix argument order if values were passed in the wrong positions"],"exampleFix":"// before\nawait renameTag(tasksPath, 'backlog'); // newName missing\n// after\nawait renameTag(tasksPath, 'backlog', 'archived-backlog');","handlingStrategy":"validation","validationCode":"if (!newName || typeof newName !== 'string') {\n  throw new Error('renameTag: newName 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 renameTag(tasksPath, oldName, newName);\n} catch (err) {\n  if (err.message.includes('New tag name is required')) {\n    console.error('Missing or invalid new tag name — prompt the user again');\n    return;\n  }\n  throw err;\n}","preventionTips":["Prompt with a required-field validator so cancellations never forward undefined","Check argument order when wrapping renameTag in helpers","Validate all rename inputs in one guard before invoking the API"],"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"}