{"record":{"id":"0989fe4983d930f3","repo":"hashicorp/terraform","slug":"task-stage-s","errorCode":null,"errorMessage":"Task Stage %s.","messagePattern":"Task Stage (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/backend_taskStages.go","lineNumber":142,"sourceCode":"\t\t\t}\n\t\t\tif ok {\n\t\t\t\tif b.CLI != nil {\n\t\t\t\t\tb.CLI.Output(\"------------------------------------------------------------------------\")\n\t\t\t\t}\n\t\t\t\treturn true, nil\n\t\t\t}\n\t\tcase tfe.TaskStageCanceled, tfe.TaskStageErrored, tfe.TaskStageFailed:\n\t\t\tok, e := processSummarizers(ctx, output, stage, summarizers, errs)\n\t\t\tif e != nil {\n\t\t\t\terrs = e\n\t\t\t}\n\t\t\tif ok {\n\t\t\t\tif b.CLI != nil {\n\t\t\t\t\tb.CLI.Output(\"------------------------------------------------------------------------\")\n\t\t\t\t}\n\t\t\t\treturn true, nil\n\t\t\t}\n\t\t\treturn false, fmt.Errorf(\"Task Stage %s.\", stage.Status)\n\t\tcase tfe.TaskStageAwaitingOverride:\n\t\t\tok, e := processSummarizers(ctx, output, stage, summarizers, errs)\n\t\t\tif e != nil {\n\t\t\t\terrs = e\n\t\t\t}\n\t\t\tif ok {\n\t\t\t\treturn true, nil\n\t\t\t}\n\t\t\tcont, err := b.processStageOverrides(ctx, output, stage.ID)\n\t\t\tif err != nil {\n\t\t\t\terrs = errors.Join(errs, err)\n\t\t\t} else {\n\t\t\t\tif b.CLI != nil {\n\t\t\t\t\tb.CLI.Output(\"------------------------------------------------------------------------\")\n\t\t\t\t}\n\t\t\t\treturn cont, nil\n\t\t\t}\n\t\tcase tfe.TaskStageUnreachable:","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/backend_taskStages.go#L124-L160","documentation":"Returned by runTaskStage polling when a task stage reaches a terminal failure status (canceled, errored, or failed) AND the summarizers did not produce a final ok continuation. The %s is the TaskStageStatus string (e.g. 'failed', 'errored', 'canceled').","triggerScenarios":"Inside the Poll loop, stage.Status is one of TaskStageCanceled/TaskStageErrored/TaskStageFailed and processSummarizers returned ok == false, so the poll stops with this error.","commonSituations":"A run task (custom task, SCA scanner, policy enforcement) executed in pre/post-plan failed or was canceled, halting the cloud run; a custom task image errored; operator canceled the task stage manually.","solutions":["Open the run URL in HCP/TFE and inspect the task stage results to find which task failed and why.","Fix the underlying task (correct task image/version, inputs, secrets) and rerun.","If a mandatory policy failed, override it (with approval) or remediate the config.","If the task was canceled inadvertently, restart the run."],"exampleFix":"// before: poll returns this error when a task fails\nreturn false, fmt.Errorf(\"Task Stage %s.\", stage.Status)\n// after (operator side): fix the failing task, then in HCP UI restart the run","handlingStrategy":"try-catch","validationCode":"// Pre-check task stage health before relying on it.\nstage, err := b.getTaskStageWithAllOptions(ctx, stageID)\nif err == nil && isTerminalFailure(stage.Status) {\n    return fmt.Errorf(\"task stage already %s; aborting before run\", stage.Status)\n}","typeGuard":"func isTerminalFailure(s tfe.TaskStageStatus) bool {\n    return s == tfe.TaskStageFailed || s == tfe.TaskStageErrored || s == tfe.TaskStageCanceled\n}","tryCatchPattern":"if err := b.waitTaskStage(ctx, cancelCtx, op, r, stage.ID, label); err != nil {\n    if strings.HasPrefix(err.Error(), \"Task Stage\") {\n        // inspect UI results, fix task, optionally override, then re-run\n    }\n    return err\n}","preventionTips":["Keep run tasks green in non-prod before promoting.","Pin task image versions and validate inputs in staging.","Pre-approve override policy if mandatory policies may soft-fail."],"tags":["terraform","cloud-backend","run-tasks","task-stage","policy","terminal"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}