{"record":{"id":"ab42874838ba4217","repo":"eyaltoledano/claude-task-master","slug":"new-tag-name-can-only-contain-letters-numbers-hy","errorCode":null,"errorMessage":"New tag name can only contain letters, numbers, hyphens, and underscores","messagePattern":"New tag name can only contain letters, numbers, hyphens, and underscores","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/tag-management.js","lineNumber":967,"sourceCode":"\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`);\n\t\t}\n\n\t\tlogFn.info(`Renaming tag from \"${oldName}\" to \"${newName}\"`);\n\n\t\t// Read current tasks data","sourceCodeStart":949,"sourceCodeEnd":985,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/tag-management.js#L949-L985","documentation":"New tag names must match /^[a-zA-Z0-9_-]+$/ — only letters, digits, hyphens, and underscores. This error is thrown when the supplied newName contains other characters such as spaces, slashes, dots, or unicode, because tags are used as object keys in tasks.json and must stay filesystem/JSON safe.","triggerScenarios":"Calling renameTag with newName containing spaces ('my tag'), slashes ('feat/x'), dots ('v1.0'), special characters ('tag!'), or empty-after-trim values like whitespace-only strings.","commonSituations":"Users typing tag names with spaces or path-like separators in the CLI; deriving tag names from branch names like 'feature/auth-refactor' (slash) or versions like '1.2.0' (dots); copy-pasting names with trailing whitespace.","solutions":["Rewrite the tag name using only letters, numbers, hyphens, and underscores (e.g. 'feature-auth' instead of 'feature/auth')","Sanitize/replace invalid characters before calling: newName.replace(/[^a-zA-Z0-9_-]/g, '-')","Trim whitespace from user input and re-prompt if the result is empty"],"exampleFix":"// before\nawait renameTag(tasksPath, 'dev', 'release 1.0');\n// after\nawait renameTag(tasksPath, 'dev', 'release-1-0');","handlingStrategy":"validation","validationCode":"const TAG_NAME_RE = /^[a-zA-Z0-9_-]+$/;\nif (!TAG_NAME_RE.test(newName)) {\n  throw new Error(`Invalid tag name \"${newName}\": use only letters, numbers, hyphens, underscores`);\n}","typeGuard":"function isValidTagName(name) {\n  return typeof name === 'string' && /^[a-zA-Z0-9_-]+$/.test(name);\n}","tryCatchPattern":"try {\n  await renameTag(tasksPath, oldName, newName);\n} catch (err) {\n  if (err.message.includes('can only contain letters, numbers, hyphens')) {\n    const sanitized = newName.trim().replace(/[^a-zA-Z0-9_-]/g, '-');\n    return renameTag(tasksPath, oldName, sanitized);\n  }\n  throw err;\n}","preventionTips":["Sanitize user input with .replace(/[^a-zA-Z0-9_-]/g, '-') before naming tags","Derive tag names from branch names by replacing '/' with '-'","Trim whitespace and reject empty results before calling the API"],"tags":["validation","naming-convention","tag-management"],"backgroundTag":"invalid-identifier-format","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}