hashicorp/terraform · error

Invalid Task stage status

Error message

Invalid Task stage status: %s 

What it means

Thrown in the default branch of the switch over stage.Status in the task-stage processing loop. Handled statuses include running, awaiting-confirmation, canceled/errored/failed, awaiting-override, and unreachable. Any other status value from the TFE TaskStages API hits this default — it's a guard against the API returning an unrecognized status the client doesn't know how to process.

Solutions

  1. Upgrade Terraform to a version whose cloud backend handles the newer task stage statuses.
  2. Upgrade/verify the TFE instance returns statuses compatible with this Terraform version.
  3. Report the unrecognized status (from the message) to the Terraform team.
  4. Retry; a transient malformed response may not recur.
Defensive patterns

Strategy: try-catch

Validate before calling

// Whitelist known statuses before processing.
var known = map[tfe.TaskStageStatus]bool{
    tfe.TaskStageRunning: true, tfe.TaskStageAwaitingConfirmation: true,
    tfe.TaskStageCanceled: true, tfe.TaskStageErrored: true, tfe.TaskStageFailed: true,
    tfe.TaskStageAwaitingOverride: true, tfe.TaskStageUnreachable: true,
}
if !known[stage.Status] { /* surface version skew */ }

Type guard

func taskStatusKnown(s tfe.TaskStageStatus) bool {
    switch s {
    case tfe.TaskStageRunning, tfe.TaskStageAwaitingConfirmation,
         tfe.TaskStageCanceled, tfe.TaskStageErrored, tfe.TaskStageFailed,
         tfe.TaskStageAwaitingOverride, tfe.TaskStageUnreachable:
        return true
    }
    return false
}

Try / catch

// default branch already does this; treat as a signal to upgrade client.

Prevention

When it happens

Trigger: The TFE/HCP API returns a task stage status that this version of the go-tfe client/cloud backend does not recognize — e.g. a new status added server-side after the client was built, or a malformed status string. This is effectively a client/server version skew or an internal bug.

Common situations: HCP Terraform introduced a new task stage status not yet handled by the Terraform client version in use; using an older Terraform against a newer TFE; a corrupted API response with an unexpected status value.

Related errors


AI-assisted analysis of hashicorp/terraform@d32a084675 (2026-08-11). Data as JSON: /api/errors/072ad607dbf0e1ea. Report an issue: GitHub.

Appendix: source

Thrown at internal/cloud/backend_taskStages.go:163

			if e != nil {
				errs = e
			}
			if ok {
				return true, nil
			}
			cont, err := b.processStageOverrides(ctx, output, stage.ID)
			if err != nil {
				errs = errors.Join(errs, err)
			} else {
				if b.CLI != nil {
					b.CLI.Output("------------------------------------------------------------------------")
				}
				return cont, nil
			}
		case tfe.TaskStageUnreachable:
			return false, nil
		default:
			return false, fmt.Errorf("Invalid Task stage status: %s ", stage.Status)
		}
		return false, errs
	})
}

func processSummarizers(ctx *IntegrationContext, output IntegrationOutputWriter, stage *tfe.TaskStage, summarizers []taskStageSummarizer, errs error) (bool, error) {
	for _, s := range summarizers {
		cont, msg, err := s.Summarize(ctx, output, stage)
		if err != nil {
			errs = errors.Join(errs, err)
			break
		}

		if !cont {
			continue
		}

		// cont is true and we must continue to poll

View on GitHub (pinned to d32a084675)