hashicorp/terraform · error
error asking for approval: %w
Error message
error asking for approval: %w
What it means
Returned during a local apply when the interactive approval prompt (op.UIIn.Input) fails to read user input. The wrapped error comes from the UI input backend (typically terminal read failure, closed stdin, or context cancellation). The apply is aborted and reported as a failure.
Source
Thrown at internal/backend/local/backend_apply.go:190
}
desc = "Terraform will perform the actions described above.\n" +
"Only 'yes' will be accepted to approve."
}
// We'll show any accumulated warnings before we display the prompt,
// so the user can consider them when deciding how to answer.
if len(diags) > 0 {
op.View.Diagnostics(diags)
diags = nil // reset so we won't show the same diagnostics again later
}
v, err := op.UIIn.Input(stopCtx, &terraform.InputOpts{
Id: "approve",
Query: "\n" + query,
Description: desc,
})
if err != nil {
diags = diags.Append(fmt.Errorf("error asking for approval: %w", err))
op.ReportResult(runningOp, diags)
return
}
if v != "yes" {
op.View.Cancelled(op.PlanMode)
runningOp.Result = backendrun.OperationFailure
return
}
} else {
// If we didn't ask for confirmation from the user, and they have
// included any failing checks in their configuration, then they
// will see a very confusing output after the apply operation
// completes. This is because all the diagnostics from the plan
// operation will now be shown alongside the diagnostics from the
// apply operation. For check diagnostics, the plan output is
// irrelevant and simple noise after the same set of checks have
// been executed again during the apply stage. As such, we are going
// to remove all diagnostics marked as check diagnostics at thisView on GitHub (pinned to c9def3e214)
Solutions
- For automation/CI, run terraform apply -auto-approve (or -input=false with a plan file) to skip the interactive prompt.
- Ensure stdin is an open TTY when running interactively; re-run in a proper terminal.
- If caused by a disconnect/interrupt, simply re-run the apply.
Example fix
# before (fails in CI without a TTY) terraform apply # after terraform apply -auto-approve # or terraform apply -input=false tfplan
Defensive patterns
Strategy: validation
Validate before calling
// For non-interactive runs, skip the prompt entirely.
if !isTTY(os.Stdin) {
op.PlanOpts = nil // or pass -input=false / -auto-approve at the CLI
} Prevention
- Always pass -auto-approve or -input=false (with a plan file) in CI/automation.
- Detect non-TTY stdin and fail fast with a clear message rather than hitting the prompt error.
- Keep interactive runs in real terminals; don't pipe stdin into apply.
When it happens
Trigger: Running terraform apply interactively but stdin is unavailable or closed, the input reader errors (broken pipe, EOF), or the stop context is cancelled mid-prompt. Also when -input=true (default) in an environment without a TTY.
Common situations: Running apply in CI/automation with -input=true (or default) where stdin is not a TTY; piping input that closes early; SSH disconnect during a prompt; misconfigured automation that doesn't pass -auto-approve or -input=false.
Related errors
- Error asking %s: %v
- Error asking for confirmation: %s
- Error asking %s: %v
- Failed to override: %w %s
- Failed to initialize config loader: %s
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/4b863fb7352db973.
Report an issue: GitHub.