hashicorp/terraform · error

Failed to override: %w %s

Error message

Failed to override: %w
%s

What it means

In checkPolicy()'s soft-failed branch: the interactive override confirmation (b.confirm) returned an error that is not errRunOverridden. This means the prompt to ask the user to type 'override' itself failed — e.g. the input read errored or the run was discarded externally while waiting — so the override could not be completed.

Source

Thrown at internal/backend/remote/backend_common.go:466

			if op.Type == backendrun.OperationTypePlan || op.UIOut == nil || op.UIIn == nil ||
				!pc.Actions.IsOverridable || !pc.Permissions.CanOverride {
				return fmt.Errorf("%s soft failed.\n%s", msgPrefix, runURL)
			}

			if op.AutoApprove {
				if _, err = b.client.PolicyChecks.Override(stopCtx, pc.ID); err != nil {
					return generalError(fmt.Sprintf("Failed to override policy check.\n%s", runURL), err)
				}
			} else {
				opts := &terraform.InputOpts{
					Id:          "override",
					Query:       "\nDo you want to override the soft failed policy check?",
					Description: "Only 'override' will be accepted to override.",
				}
				err = b.confirm(stopCtx, op, opts, r, "override")
				if err != nil && err != errRunOverridden {
					return fmt.Errorf("Failed to override: %w\n%s\n", err, runURL)
				}

				if err != errRunOverridden {
					if _, err = b.client.PolicyChecks.Override(stopCtx, pc.ID); err != nil {
						return generalError(fmt.Sprintf("Failed to override policy check.\n%s", runURL), err)
					}
				} else {
					runURL := fmt.Sprintf(runHeader, b.hostname, b.organization, op.Workspace, r.ID)
					b.CLI.Output(fmt.Sprintf("The run needs to be manually overridden or discarded.\n%s\n", runURL))
				}
			}

			if b.CLI != nil {
				b.CLI.Output("------------------------------------------------------------------------")
			}
		default:
			return fmt.Errorf("Unknown or unexpected policy state: %s", pc.Status)
		}

View on GitHub (pinned to c9def3e214)

Solutions

  1. Re-run the apply; if the run was concurrently resolved in the UI, start a fresh run.
  2. Perform the override directly in the HCP/TFE UI via the run URL shown.
  3. Ensure the terminal/embedding environment provides a working interactive input (UIIn).
  4. Use `terraform apply -auto-approve` (with override permission granted) to skip the interactive prompt.
Defensive patterns

Strategy: try-catch

Type guard

func isRunOverriddenMarker(err error) bool {
    return errors.Is(err, errRunOverridden)
}

Try / catch

err = b.confirm(stopCtx, op, opts, r, "override")
if err != nil && err != errRunOverridden {
    return fmt.Errorf("Failed to override: %w\n%s", err, runURL)
}

Prevention

When it happens

Trigger: During an interactive apply where a soft policy failed and is overridable, b.confirm() is called to prompt 'Do you want to override...'; it returns an error other than errRunOverridden (e.g. UIIn.Input failed, the run was discarded via UI mid-prompt, or context canceled in a non-clean way).

Common situations: Terminal/EOF closed while the override prompt was waiting; the run was discarded or approved via the web UI concurrently, making the prompt stale; a broken interactive UI in the embedding tool.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/fc8aadb60e3e1ffc. Report an issue: GitHub.