{"record":{"id":"30ea5cd9e91402b3","repo":"eyaltoledano/claude-task-master","slug":"invalid-format-options-format-valid-formats-a","errorCode":null,"errorMessage":"Invalid format: ${options.format}. Valid formats are: text, json","messagePattern":"Invalid format: (.+?)\\. Valid formats are: text, json","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/cli/src/commands/generate.command.ts","lineNumber":95,"sourceCode":"\t\t\tthis.displayResults(result, options);\n\t\t} catch (error: any) {\n\t\t\thasError = true;\n\t\t\tdisplayError(error, { skipExit: true });\n\t\t} finally {\n\t\t\tawait this.cleanup();\n\t\t}\n\n\t\tif (hasError) {\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\t/**\n\t * Validate command options\n\t */\n\tprivate validateOptions(options: GenerateCommandOptions): void {\n\t\tif (options.format && !['text', 'json'].includes(options.format)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid format: ${options.format}. Valid formats are: text, json`\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Initialize TmCore\n\t */\n\tprivate async initializeCore(projectRoot: string): Promise<void> {\n\t\tif (!this.tmCore) {\n\t\t\tconst resolved = path.resolve(projectRoot);\n\t\t\tthis.tmCore = await createTmCore({ projectPath: resolved });\n\t\t}\n\t}\n\n\t/**\n\t * Generate task files using tm-core\n\t */","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/apps/cli/src/commands/generate.command.ts#L77-L113","documentation":"copyTag enforces that the target tag key is not already present in the tagged data, since tags are object keys and copying into an existing tag would overwrite its tasks. Throwing prevents silent data loss.","triggerScenarios":"Calling copyTag with a targetName that already exists in tasks.json, including re-running the same copy-tag command twice.","commonSituations":"Idempotent automation scripts re-executing copy-tag; picking a target name that duplicates an existing tag; forgetting a previous copy operation already succeeded.","solutions":["Choose a unique target tag name","Delete or rename the existing target tag first if its contents are disposable","Add an existence guard (task-master tags) in scripts before calling copyTag"],"exampleFix":"// before\nawait copyTag(tasksPath, 'backlog', 'sprint-1'); // sprint-1 exists\n// after\nif (!tagsData['sprint-1']) await copyTag(tasksPath, 'backlog', 'sprint-1');","handlingStrategy":"validation","validationCode":"const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));\nif (data[targetName] || (data.tags && data.tags[targetName])) {\n  throw new Error(`Target tag already exists: ${targetName}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await copyTag(tasksPath, source, target);\n} catch (e) {\n  if (e.message.includes('already exists')) {\n    const unique = `${target}-${Date.now()}`;\n    return copyTag(tasksPath, source, unique);\n  }\n  throw e;\n}","preventionTips":["Make copy-tag scripts idempotent with existence checks","Use unique, timestamped names for backup-style tags","Clean up old tags before re-running automation"],"tags":["validation","tag-management","idempotency"],"backgroundTag":"duplicate-tag","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}