{"record":{"id":"b875be18d344b3dc","repo":"eyaltoledano/claude-task-master","slug":"unknown-tdd-phase-tddphase","errorCode":null,"errorMessage":"Unknown TDD phase: ${tddPhase}","messagePattern":"Unknown TDD phase: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/workflow/services/workflow.service.ts","lineNumber":447,"sourceCode":"\t\tswitch (tddPhase) {\n\t\t\tcase 'RED':\n\t\t\t\tawait this.orchestrator.transition({\n\t\t\t\t\ttype: 'RED_PHASE_COMPLETE',\n\t\t\t\t\ttestResults\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase 'GREEN':\n\t\t\t\tawait this.orchestrator.transition({\n\t\t\t\t\ttype: 'GREEN_PHASE_COMPLETE',\n\t\t\t\t\ttestResults\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\tcase 'COMMIT':\n\t\t\t\tthrow new Error(\n\t\t\t\t\t'Cannot complete COMMIT phase with test results. Use commit() instead.'\n\t\t\t\t);\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Unknown TDD phase: ${tddPhase}`);\n\t\t}\n\n\t\treturn this.getStatus();\n\t}\n\n\t/**\n\t * Commit current changes and advance workflow\n\t */\n\tasync commit(): Promise<WorkflowStatus> {\n\t\tif (!this.orchestrator) {\n\t\t\tthrow new Error('No active workflow. Start or resume a workflow first.');\n\t\t}\n\n\t\tconst tddPhase = this.orchestrator.getCurrentTDDPhase();\n\n\t\tif (tddPhase !== 'COMMIT') {\n\t\t\tthrow new Error(\n\t\t\t\t`Cannot commit in ${tddPhase} phase. Complete RED and GREEN phases first.`","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/workflow/services/workflow.service.ts#L429-L465","documentation":"completePhase() switches on the current TDD phase and only recognizes RED, GREEN, and COMMIT. Any other value (e.g. a phase string from a newer/older state file or an internal state-machine bug) falls into the default branch and throws 'Unknown TDD phase: <value>'. This should be unreachable with valid state and usually indicates corrupted or version-skewed persisted state.","triggerScenarios":"Resuming a workflow whose persisted state contains a TDD phase value the current code does not recognize (version mismatch between saved state and library version); a corrupted .taskmaster/workflow state file; internal state machine regression producing an unexpected phase value.","commonSituations":"Upgrading the package while a workflow state file from the old version is still on disk; hand-editing or partial writes to the state file; plugin/custom transitions injecting unknown phase values.","solutions":["Abort the stale workflow (abortWorkflow()) or delete the state file and start a new one with startWorkflow()","Check for a package version mismatch: upgrade/downgrade @tm/core so it matches the version that wrote the state","Inspect the persisted workflow state file for a corrupted tddPhase value","If reproducible on current versions, report a bug with the state file and the logged phase value"],"exampleFix":"// before\nawait workflowService.completePhase(results); // throws Unknown TDD phase: LEGACY\n// after\ntry {\n  await workflowService.completePhase(results);\n} catch (e) {\n  if (String(e.message).startsWith('Unknown TDD phase')) {\n    await workflowService.abortWorkflow();\n    await workflowService.startWorkflow(taskConfig); // fresh state\n  } else throw e;\n}","handlingStrategy":"fallback","validationCode":"const tdd = workflowService.getStatus().tddPhase;\nconst known = ['RED','GREEN','COMMIT'].includes(tdd as string);\nif (!known) {\n  // stale/corrupt state from another version: abort and restart\n  await workflowService.abortWorkflow();\n}","typeGuard":"function isKnownTddPhase(v: unknown): v is 'RED'|'GREEN'|'COMMIT' {\n  return v === 'RED' || v === 'GREEN' || v === 'COMMIT';\n}","tryCatchPattern":"try {\n  await workflowService.completePhase(results);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unknown TDD phase')) {\n    await workflowService.abortWorkflow();\n    await workflowService.startWorkflow(taskConfig); // fresh valid state\n  } else throw e;\n}","preventionTips":["Ensure the library version that reads the state file matches the version that wrote it","Do not hand-edit the persisted workflow state file","Abort and restart workflows after upgrading @tm/core if a state file exists","Validate the state file's tddPhase after resume; abort on unknown values"],"tags":["workflow","state-machine","version-mismatch"],"backgroundTag":"invalid-workflow-phase","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}