{"record":{"id":"98e7a2cac396ffe1","repo":"hashicorp/terraform","slug":"error-asking-s-v","errorCode":null,"errorMessage":"Error asking %s: %v","messagePattern":"Error asking (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote/backend_common.go","lineNumber":557,"sourceCode":"\n\t\t\t\t\tif err == errRunDiscarded {\n\t\t\t\t\t\terr = errApplyDiscarded\n\t\t\t\t\t\tif op.PlanMode == plans.DestroyMode {\n\t\t\t\t\t\t\terr = errDestroyDiscarded\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tresult <- err\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\n\tresult <- func() error {\n\t\tv, err := op.UIIn.Input(doneCtx, opts)\n\t\tif err != nil && err != context.Canceled && stopCtx.Err() != context.Canceled {\n\t\t\treturn fmt.Errorf(\"Error asking %s: %v\", opts.Id, err)\n\t\t}\n\n\t\t// We return the error of our parent channel as we don't\n\t\t// care about the error of the doneCtx which is only used\n\t\t// within this function. So if the doneCtx was canceled\n\t\t// because stopCtx was canceled, this will properly return\n\t\t// a context.Canceled error and otherwise it returns nil.\n\t\tif doneCtx.Err() == context.Canceled || stopCtx.Err() == context.Canceled {\n\t\t\treturn stopCtx.Err()\n\t\t}\n\n\t\t// Make sure we cancel the context here so the loop that\n\t\t// checks for external changes to the run is ended before\n\t\t// we start to make changes ourselves.\n\t\tcancel()\n\n\t\tif v != keyword {\n\t\t\t// Retrieve the run again to get its current status.","sourceCodeStart":539,"sourceCodeEnd":575,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/backend/remote/backend_common.go#L539-L575","documentation":"In confirm(), op.UIIn.Input() returned an error that is neither context.Canceled nor caused by stopCtx being canceled. It means the interactive input read (the prompt for 'yes'/'override') failed for a genuine reason — EOF, broken pipe, or the UI implementation errored — not because the operation was cleanly canceled.","triggerScenarios":"confirm() calls op.UIIn.Input(doneCtx, opts) to read the user's typed confirmation; the call errors with something other than context.Canceled (e.g. io.EOF from a closed stdin, a broken terminal, or an embedded UI implementation returning an error). opts.Id is interpolated so the message names which prompt failed.","commonSituations":"Piping input or running in CI without a TTY where the prompt can't be answered; stdin closed unexpectedly; a wrapper tool's interactive UI broke; pressing Ctrl-D (EOF) at the prompt instead of typing yes/override.","solutions":["Run in a real terminal, or supply `-auto-approve` / pipe the expected keyword so no interactive read is needed.","For CI, avoid interactive prompts entirely by pre-approving or using the auto-approve flag.","If embedding, ensure the UIIn implementation returns context.Canceled on shutdown rather than a raw error."],"exampleFix":"// before - interactive prompt fails in headless CI\n$ terraform apply   # prompts for 'yes', stdin is closed -> EOF\n\n// after - auto-approve or feed input\n$ terraform apply -auto-approve\n# or\n$ echo yes | terraform apply","handlingStrategy":"try-catch","validationCode":"// Ensure an interactive UI is available before prompting.\nfunc canPrompt(op *backendrun.Operation) bool {\n    return op.UIIn != nil && op.UIOut != nil\n}","typeGuard":"func isContextCanceled(err error) bool {\n    return errors.Is(err, context.Canceled)\n}","tryCatchPattern":"v, err := op.UIIn.Input(doneCtx, opts)\nif err != nil && err != context.Canceled && stopCtx.Err() != context.Canceled {\n    return fmt.Errorf(\"Error asking %s: %w\", opts.Id, err)\n}","preventionTips":["Use `-auto-approve` or pipe the expected keyword in non-interactive/CI contexts.","Run in a real TTY when interactive confirmation is required.","In embedding code, return context.Canceled (not a raw error) from UIIn on shutdown."],"tags":["input","ui","interactive","confirm"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}