eyaltoledano/claude-task-master · error · Error
New tag name can only contain letters, numbers, hyphens, and
Error message
New tag name can only contain letters, numbers, hyphens, and underscores
What it means
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.
Source
Thrown at scripts/modules/task-manager/tag-management.js:967
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 (!oldName || typeof oldName !== 'string') {
throw new Error('Old tag name is required and must be a string');
}
if (!newName || typeof newName !== 'string') {
throw new Error('New tag name is required and must be a string');
}
// Validate new tag name format
if (!/^[a-zA-Z0-9_-]+$/.test(newName)) {
throw new Error(
'New tag name can only contain letters, numbers, hyphens, and underscores'
);
}
// Prevent renaming master tag
if (oldName === 'master') {
throw new Error('Cannot rename the "master" tag');
}
// Reserved tag names
const reservedNames = ['master', 'main', 'default'];
if (reservedNames.includes(newName.toLowerCase())) {
throw new Error(`"${newName}" is a reserved tag name`);
}
logFn.info(`Renaming tag from "${oldName}" to "${newName}"`);
// Read current tasks dataView on GitHub (pinned to c0c98d367c)
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
Example fix
// before await renameTag(tasksPath, 'dev', 'release 1.0'); // after await renameTag(tasksPath, 'dev', 'release-1-0');
Defensive patterns
Strategy: validation
Validate before calling
const TAG_NAME_RE = /^[a-zA-Z0-9_-]+$/;
if (!TAG_NAME_RE.test(newName)) {
throw new Error(`Invalid tag name "${newName}": use only letters, numbers, hyphens, underscores`);
} Type guard
function isValidTagName(name) {
return typeof name === 'string' && /^[a-zA-Z0-9_-]+$/.test(name);
} Try / catch
try {
await renameTag(tasksPath, oldName, newName);
} catch (err) {
if (err.message.includes('can only contain letters, numbers, hyphens')) {
const sanitized = newName.trim().replace(/[^a-zA-Z0-9_-]/g, '-');
return renameTag(tasksPath, oldName, sanitized);
}
throw err;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- "${newName}" is a reserved tag name
- MFA_VERIFICATION_FAILED
- Failed to initialize services: ${(error as Error).message}
- Invalid format: ${options.format}. Valid formats are: text,
- Failed to fetch tasks from any tag. First error: ${failedTag
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/ab42874838ba4217.
Report an issue: GitHub.