{"record":{"id":"f11cf43632bbfeb8","repo":"eyaltoledano/claude-task-master","slug":"old-tag-name-is-required-and-must-be-a-string","errorCode":null,"errorMessage":"Old tag name is required and must be a string","messagePattern":"Old 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":959,"sourceCode":"\toptions = {},\n\tcontext = {},\n\toutputFormat = 'text'\n) {\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","sourceCodeStart":941,"sourceCodeEnd":977,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/tag-management.js#L941-L977","documentation":"renameTag() validates its parameters before doing any work. This error is thrown when the oldName argument is missing, null, undefined, an empty string, or not a string type. It is a guard so the tag lookup rawData[oldName] always receives a usable string key.","triggerScenarios":"Calling renameTag(tasksPath, oldName, newName, ...) with oldName omitted, passed as undefined/null, as an empty string, or as a non-string (number, object) — e.g. programmatic callers that forward CLI args or MCP tool params without checking they were provided.","commonSituations":"CLI wrappers forgetting to forward the positional tag argument; MCP tool invocations missing the required parameter; scripting against the API with variables that were never assigned; destructuring mistakes producing undefined.","solutions":["Pass the existing tag name as the second argument to renameTag as a non-empty string","Validate the argument before calling: if (!oldName || typeof oldName !== 'string') throw ...","Check the CLI/MCP layer is actually forwarding the tag parameter instead of dropping it"],"exampleFix":"// before\nawait renameTag(tasksPath, opts.tag, opts.newName);\n// after\nif (!opts.tag || typeof opts.tag !== 'string') {\n  throw new Error('renameTag requires the current tag name');\n}\nawait renameTag(tasksPath, opts.tag, opts.newName);","handlingStrategy":"validation","validationCode":"function canRename(oldName, newName) {\n  return typeof oldName === 'string' && oldName.length > 0 &&\n         typeof newName === 'string' && newName.length > 0;\n}\nif (!canRename(oldName, newName)) throw new Error('oldName and newName must be non-empty strings');","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('Old tag name is required')) {\n    console.error(`Invalid source tag argument: ${JSON.stringify(oldName)}`);\n    return;\n  }\n  throw err;\n}","preventionTips":["Always source tag names from `task-master tags` output, never hardcode unverified values","Validate CLI/MCP parameters at the boundary before calling library functions","Use a small wrapper around renameTag that validates both names first"],"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"}