hashicorp/terraform · error

Failed to override: %w %s

Error message

Failed to override: %w
%s

What it means

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.

Source

Thrown at internal/cloud/backend_taskStages.go:203

		return true, nil
	}
	return false, errs
}

func (b *Cloud) processStageOverrides(context *IntegrationContext, output IntegrationOutputWriter, taskStageID string) (bool, error) {
	if b.CLI != nil {
		b.CLI.Output("--------------------------------\n")
		b.CLI.Output(b.Colorize().Color(fmt.Sprintf("%c%c [bold]Override", Arrow, Arrow)))
	}
	opts := &terraform.InputOpts{
		Id:          fmt.Sprintf("%c%c [bold]Override", Arrow, Arrow),
		Query:       "\nDo you want to override the failed policies?",
		Description: "Only 'override' will be accepted to override.",
	}
	runURL := fmt.Sprintf(taskStageHeader, b.Hostname, b.Organization, context.Op.Workspace, context.Run.ID)
	err := b.confirm(context.StopContext, context.Op, opts, context.Run, "override")
	if err != nil && err != errRunOverridden {
		return false, fmt.Errorf("Failed to override: %w\n%s\n", err, runURL)
	}

	if err != errRunOverridden {
		if _, err = b.client.TaskStages.Override(context.StopContext, taskStageID, tfe.TaskStageOverrideOptions{}); err != nil {
			return false, b.generalError(fmt.Sprintf("Failed to override policy check.\n%s", runURL), err)
		} else {
			return true, nil
		}
	} else {
		output.Output(fmt.Sprintf("The run needs to be manually overridden or discarded.\n%s\n", runURL))
	}
	return false, nil
}

View on GitHub (pinned to c9def3e214)

Solutions

  1. Re-run interactively and answer the override prompt correctly (type 'override' to override).
  2. If running non-interactively, pre-approve via the appropriate flag/env or handle the override in the HCP UI.
  3. Use the run URL in the error message to override or discard the run manually in the UI.
  4. Remediate the config so the policy passes instead of overriding.

Example fix

// before: non-interactive run hits override prompt and errors
// after: set auto-override via approved workflow, or override in UI using the run URL
Defensive patterns

Strategy: validation

Validate before calling

// Ensure interactivity before reaching the override prompt.
if !isInteractive(op) {
    return fmt.Errorf("cannot prompt for override non-interactively; pre-approve or use UI")
}

Try / catch

cont, err := b.processStageOverrides(ctx, output, stage.ID)
if err != nil && strings.Contains(err.Error(), "Failed to override") {
    // surface run URL; let operator override/discard in UI, then re-run
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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