{"record":{"id":"4b863fb7352db973","repo":"hashicorp/terraform","slug":"error-asking-for-approval-w","errorCode":null,"errorMessage":"error asking for approval: %w","messagePattern":"error asking for approval: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/local/backend_apply.go","lineNumber":190,"sourceCode":"\t\t\t\t}\n\t\t\t\tdesc = \"Terraform will perform the actions described above.\\n\" +\n\t\t\t\t\t\"Only 'yes' will be accepted to approve.\"\n\t\t\t}\n\n\t\t\t// We'll show any accumulated warnings before we display the prompt,\n\t\t\t// so the user can consider them when deciding how to answer.\n\t\t\tif len(diags) > 0 {\n\t\t\t\top.View.Diagnostics(diags)\n\t\t\t\tdiags = nil // reset so we won't show the same diagnostics again later\n\t\t\t}\n\n\t\t\tv, err := op.UIIn.Input(stopCtx, &terraform.InputOpts{\n\t\t\t\tId:          \"approve\",\n\t\t\t\tQuery:       \"\\n\" + query,\n\t\t\t\tDescription: desc,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\tdiags = diags.Append(fmt.Errorf(\"error asking for approval: %w\", err))\n\t\t\t\top.ReportResult(runningOp, diags)\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif v != \"yes\" {\n\t\t\t\top.View.Cancelled(op.PlanMode)\n\t\t\t\trunningOp.Result = backendrun.OperationFailure\n\t\t\t\treturn\n\t\t\t}\n\t\t} else {\n\t\t\t// If we didn't ask for confirmation from the user, and they have\n\t\t\t// included any failing checks in their configuration, then they\n\t\t\t// will see a very confusing output after the apply operation\n\t\t\t// completes. This is because all the diagnostics from the plan\n\t\t\t// operation will now be shown alongside the diagnostics from the\n\t\t\t// apply operation. For check diagnostics, the plan output is\n\t\t\t// irrelevant and simple noise after the same set of checks have\n\t\t\t// been executed again during the apply stage. As such, we are going\n\t\t\t// to remove all diagnostics marked as check diagnostics at this","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/local/backend_apply.go#L172-L208","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before (fails in CI without a TTY)\nterraform apply\n# after\nterraform apply -auto-approve\n# or\nterraform apply -input=false tfplan","handlingStrategy":"validation","validationCode":"// For non-interactive runs, skip the prompt entirely.\nif !isTTY(os.Stdin) {\n    op.PlanOpts = nil // or pass -input=false / -auto-approve at the CLI\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["ui","apply","interactive","ci","terraform"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}