{"record":{"id":"3b79adc170af910e","repo":"hashicorp/terraform","slug":"interrupted","errorCode":null,"errorMessage":"interrupted","messagePattern":"interrupted","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"internal/command/ui_input.go","lineNumber":79,"sourceCode":"\t}\n\tif w == nil {\n\t\tw = defaultInputWriter\n\t}\n\tif r == nil {\n\t\tr = os.Stdin\n\t}\n\tif w == nil {\n\t\tw = os.Stdout\n\t}\n\n\t// Make sure we only ask for input once at a time. Terraform\n\t// should enforce this, but it doesn't hurt to verify.\n\ti.l.Lock()\n\tdefer i.l.Unlock()\n\n\t// If we're interrupted, then don't ask for input\n\tif i.interrupted {\n\t\treturn \"\", errors.New(\"interrupted\")\n\t}\n\n\tlog.Printf(\"[DEBUG] command: asking for input: %q\", opts.Query)\n\n\t// Listen for interrupts so we can cancel the input ask\n\tsigCh := make(chan os.Signal, 1)\n\tsignal.Notify(sigCh, os.Interrupt)\n\tdefer signal.Stop(sigCh)\n\n\t// Build the output format for asking\n\tvar buf bytes.Buffer\n\tbuf.WriteString(\"[reset]\")\n\tbuf.WriteString(fmt.Sprintf(\"[bold]%s[reset]\\n\", opts.Query))\n\tif opts.Description != \"\" {\n\t\ts := bufio.NewScanner(strings.NewReader(opts.Description))\n\t\tfor s.Scan() {\n\t\t\tbuf.WriteString(fmt.Sprintf(\"  %s\\n\", s.Text()))\n\t\t}","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/ui_input.go#L61-L97","documentation":"Returned by UIInput.Input (ui_input.go:79). UIInput tracks an `interrupted` flag; once a prior SIGINT set it (see error 77), every subsequent Input() call returns errors.New(\"interrupted\") immediately at the top of the function without prompting. This prevents re-prompting after the operator already cancelled.","triggerScenarios":"Terraform is mid-prompt and the operator pressed Ctrl-C; a later code path (e.g. a follow-up variable prompt, or a confirm) calls Input() again and gets \"interrupted\" because the flag is already set.","commonSituations":"Pressing Ctrl-C during a variable prompt then Terraform trying another prompt; interrupted apply where multiple inputs are queued; tests that do not reset UIInput.interrupted between runs.","solutions":["Treat it as the expected consequence of an interrupt: stop the run and re-invoke the command fresh once ready.","Provide all required inputs up front via -var / var files / TF_VAR_* so no interactive prompts are needed and Ctrl-C mid-prompt never happens.","In automation, avoid sending SIGINT to a process mid-prompt; supply inputs non-interactively instead."],"exampleFix":"# before\n terraform apply   # prompted for var, you hit ^C, next prompt -> interrupted\n# after (supply vars, no prompts)\n terraform apply -var-file=prod.tfvars -auto-approve","handlingStrategy":"try-catch","validationCode":"// Supply all inputs so UIInput is never invoked, avoiding the interrupted flag entirely.\n if len(missingVars(cfg)) > 0 && !interactive {\n     return errors.New(\"supply -var / *.auto.tfvars to avoid prompts\")\n }","typeGuard":null,"tryCatchPattern":"v, err := uiInput.Input(ctx, opts)\n if err != nil && err.Error() == \"interrupted\" {\n     // prior interrupt; abort the run cleanly\n     return\n }","preventionTips":["Provide variables via -var / *.auto.tfvars / TF_VAR_* so no prompts are issued.","Reset the UIInput.interrupted flag in tests between runs."],"tags":["input","interrupt","interactive","signal-handling"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}