{"record":{"id":"48371b4b1e584bec","repo":"hashicorp/terraform","slug":"failed-to-override-w-s-48371b","errorCode":null,"errorMessage":"Failed to override: %w\n%s\n","messagePattern":"Failed to override: %w\n(.+?)\n","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/backend_taskStages.go","lineNumber":203,"sourceCode":"\t\treturn true, nil\n\t}\n\treturn false, errs\n}\n\nfunc (b *Cloud) processStageOverrides(context *IntegrationContext, output IntegrationOutputWriter, taskStageID string) (bool, error) {\n\tif b.CLI != nil {\n\t\tb.CLI.Output(\"--------------------------------\\n\")\n\t\tb.CLI.Output(b.Colorize().Color(fmt.Sprintf(\"%c%c [bold]Override\", Arrow, Arrow)))\n\t}\n\topts := &terraform.InputOpts{\n\t\tId:          fmt.Sprintf(\"%c%c [bold]Override\", Arrow, Arrow),\n\t\tQuery:       \"\\nDo you want to override the failed policies?\",\n\t\tDescription: \"Only 'override' will be accepted to override.\",\n\t}\n\trunURL := fmt.Sprintf(taskStageHeader, b.Hostname, b.Organization, context.Op.Workspace, context.Run.ID)\n\terr := b.confirm(context.StopContext, context.Op, opts, context.Run, \"override\")\n\tif err != nil && err != errRunOverridden {\n\t\treturn false, fmt.Errorf(\"Failed to override: %w\\n%s\\n\", err, runURL)\n\t}\n\n\tif err != errRunOverridden {\n\t\tif _, err = b.client.TaskStages.Override(context.StopContext, taskStageID, tfe.TaskStageOverrideOptions{}); err != nil {\n\t\t\treturn false, b.generalError(fmt.Sprintf(\"Failed to override policy check.\\n%s\", runURL), err)\n\t\t} else {\n\t\t\treturn true, nil\n\t\t}\n\t} else {\n\t\toutput.Output(fmt.Sprintf(\"The run needs to be manually overridden or discarded.\\n%s\\n\", runURL))\n\t}\n\treturn false, nil\n}\n","sourceCodeStart":185,"sourceCodeEnd":217,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/backend_taskStages.go#L185-L217","documentation":"Returned by processStageOverrides when the interactive confirmation prompt (b.confirm) for overriding a failed policy/task returns an error that is not errRunOverridden. The error is wrapped along with the run URL so the user knows where to finish the override manually.","triggerScenarios":"During a TaskStageAwaitingOverride, the override confirmation UI returns an error other than errRunOverridden — e.g. user canceled input, input read failed, context cancelled, or the prompt was interrupted.","commonSituations":"User pressed Ctrl-C at the 'Do you want to override the failed policies?' prompt; non-interactive run that hit an awaiting-override stage with no TTY; input stream error; the confirm helper's state machine hit an unexpected branch.","solutions":["Re-run interactively and answer the override prompt correctly (type 'override' to override).","If running non-interactively, pre-approve via the appropriate flag/env or handle the override in the HCP UI.","Use the run URL in the error message to override or discard the run manually in the UI.","Remediate the config so the policy passes instead of overriding."],"exampleFix":"// before: non-interactive run hits override prompt and errors\n// after: set auto-override via approved workflow, or override in UI using the run URL","handlingStrategy":"validation","validationCode":"// Ensure interactivity before reaching the override prompt.\nif !isInteractive(op) {\n    return fmt.Errorf(\"cannot prompt for override non-interactively; pre-approve or use UI\")\n}","typeGuard":null,"tryCatchPattern":"cont, err := b.processStageOverrides(ctx, output, stage.ID)\nif err != nil && strings.Contains(err.Error(), \"Failed to override\") {\n    // surface run URL; let operator override/discard in UI, then re-run\n}","preventionTips":["Run interactively when overrides are expected.","Provide non-interactive override approval via approved automation.","Always include the run URL in user-facing diagnostics."],"tags":["terraform","cloud-backend","policy-override","interactive","task-stage"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}