eyaltoledano/claude-task-master · error · AuthenticationError

MFA_VERIFICATION_FAILED

MFA_VERIFICATION_FAILED

Error message

MFA challenge information missing

What it means

copyTag validates the target tag name against /^[a-zA-Z0-9_-]+$/ before copying tasks from a source tag. If the targetName contains any other characters (spaces, slashes, dots, unicode), this error is thrown to keep tag names valid as keys in the tagged tasks data structure. It is a pre-write guard so invalid tags never enter tasks.json.

Source

Thrown at apps/cli/src/commands/auth.command.ts:520

	 */
	private async authenticateWithToken(token: string): Promise<AuthCredentials> {
		const spinner = ora('Verifying authentication token...').start();

		try {
			const credentials = await this.authManager.authenticateWithCode(token);
			spinner.succeed('Successfully authenticated!');
			return credentials;
		} catch (error) {
			// Check if MFA is required BEFORE showing failure message
			if (
				error instanceof AuthenticationError &&
				error.code === 'MFA_REQUIRED'
			) {
				// Stop spinner without showing failure - MFA is required, not a failure
				spinner.stop();

				if (!error.mfaChallenge?.factorId) {
					throw new AuthenticationError(
						'MFA challenge information missing',
						'MFA_VERIFICATION_FAILED'
					);
				}

				// Use shared MFA flow handler
				return this.handleMFAVerification(error);
			}

			// Only show "Authentication failed" for actual failures
			spinner.fail('Authentication failed');
			throw error;
		}
	}

	/**
	 * Handle MFA verification flow
	 * Uses shared MFA utilities from auth-ui.ts

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Remove or replace invalid characters in the target name (replace [^a-zA-Z0-9_-] with '-')
  2. Use sanitizeBranchNameForTag() (or equivalent sanitization) before calling copyTag
  3. Keep tag names lowercase alphanum with hyphens/underscores only

Example fix

// before
await copyTag(tasksPath, 'backlog', 'feature/new-ui');
// after
await copyTag(tasksPath, 'backlog', 'feature-new-ui');
Defensive patterns

Strategy: validation

Validate before calling

function isValidTagName(name){return typeof name==='string' && /^[a-zA-Z0-9_-]+$/.test(name);}
if (!isValidTagName(targetName)) throw new Error('Invalid target tag name: '+targetName);

Type guard

const isTagName = (v: unknown): v is string => typeof v === 'string' && /^[a-zA-Z0-9_-]+$/.test(v);

Try / catch

try {
  await copyTag(tasksPath, source, target);
} catch (e) {
  if (e.message.includes('can only contain')) {
    const sanitized = target.replace(/[^a-zA-Z0-9_-]/g, '-');
    return copyTag(tasksPath, source, sanitized);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling copyTag (or `task-master copy-tag`) with a target name containing whitespace, slashes (e.g. 'feature/x'), dots, or other non [a-zA-Z0-9_-] characters, or an empty/undefined targetName.

Common situations: Deriving a tag name from a branch name like 'feature/login-flow' or a version string 'v1.2' without sanitizing; passing a user-supplied tag from a UI or script with spaces.

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/13bdf5322c5d5e15. Report an issue: GitHub.