{"record":{"id":"4b6e942f714e574f","repo":"hashicorp/terraform","slug":"error-asking-for-input-to-configure-backend-q-s","errorCode":null,"errorMessage":"Error asking for input to configure backend %q: %s","messagePattern":"Error asking for input to configure backend %q: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/meta_backend.go","lineNumber":2719,"sourceCode":"\tdiags = diags.Append(hclDiags)\n\tif hclDiags.HasErrors() {\n\t\treturn nil, cty.NilVal, diags\n\t}\n\n\tif !configVal.IsWhollyKnown() {\n\t\tdiags = diags.Append(tfdiags.Sourceless(\n\t\t\ttfdiags.Error,\n\t\t\t\"Unknown values within backend definition\",\n\t\t\t\"The `terraform` configuration block should contain only concrete and static values. Another diagnostic should contain more information about which part of the configuration is problematic.\"))\n\t\treturn nil, cty.NilVal, diags\n\t}\n\n\t// TODO: test\n\tif m.Input() {\n\t\tvar err error\n\t\tconfigVal, err = m.inputForSchema(configVal, schema)\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(fmt.Errorf(\"Error asking for input to configure backend %q: %s\", c.Type, err))\n\t\t}\n\n\t\t// We get an unknown here if the if the user aborted input, but we can't\n\t\t// turn that into a config value, so set it to null and let the provider\n\t\t// handle it in PrepareConfig.\n\t\tif !configVal.IsKnown() {\n\t\t\tconfigVal = cty.NullVal(configVal.Type())\n\t\t}\n\t}\n\n\tnewVal, validateDiags := b.PrepareConfig(configVal)\n\tdiags = diags.Append(validateDiags.InConfigBody(c.Config, \"\"))\n\tif validateDiags.HasErrors() {\n\t\treturn nil, cty.NilVal, diags\n\t}\n\n\tconfigureDiags := b.Configure(newVal)\n\tdiags = diags.Append(configureDiags.InConfigBody(c.Config, \"\"))","sourceCodeStart":2701,"sourceCodeEnd":2737,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/meta_backend.go#L2701-L2737","documentation":"During interactive backend configuration (m.Input() true), inputForSchema prompts the user for missing backend attributes and returned an error. Wrapped %s is the prompt/IO failure. This is about the interactive input session, not the backend config validity itself.","triggerScenarios":"m.inputForSchema(configVal, schema) errors while prompting for backend inputs. Triggers: non-interactive (no TTY) run with Input enabled, EOF/Ctrl-C during prompt, a UIInput implementation error, or stdin closed in CI/pipe mode.","commonSituations":"Running `tofu init` in CI/containers without a TTY but with input enabled; piping stdin that closes mid-prompt; an embedded terraform use that did not wire UIInput; user pressed Ctrl-C at a backend prompt.","solutions":["Run in an interactive TTY when backend input is needed, or supply all required backend attributes in config so no prompt is required.","Disable input (`-input=false`) and provide a complete backend/state_store config plus overrides via `-backend-config=`.","In embedded use, provide a working UIInput implementation before enabling Input.","Ensure stdin is not prematurely closed (avoid `echo | tofu init` for interactive prompts)."],"exampleFix":"// before\ntofu init  # no TTY in CI, backend block missing required fields\n# -> Error asking for input to configure backend \"s3\"\n\n// after: non-interactive, all values supplied\ntofu init -input=false -backend-config=\"bucket=mybucket\" -backend-config=\"region=us-east-1\"","handlingStrategy":"try-catch","validationCode":"// Only enable interactive input when a usable TTY is attached; otherwise\n// require complete config.\nfunc shouldPromptForBackend(isTTY bool, configComplete bool) bool {\n    return isTTY && !configComplete\n}\n\n// In non-TTY contexts, fail fast with a clear message instead of prompting.\nif m.Input() && !isTerminal(os.Stdin) {\n    return fmt.Errorf(\"backend block is incomplete and stdin is not a TTY; supply all required attributes or run with -input=false\")\n}","typeGuard":null,"tryCatchPattern":"configVal, err = m.inputForSchema(configVal, schema)\nif err != nil {\n    if isNoTTYErr(err) || errors.Is(err, io.EOF) {\n        diags = diags.Append(fmt.Errorf(\"cannot prompt for backend %q without a TTY; provide all values in config or use -backend-config= (-input=false): %s\", c.Type, err))\n    } else {\n        diags = diags.Append(fmt.Errorf(\"Error asking for input to configure backend %q: %s\", c.Type, err))\n    }\n}","preventionTips":["Provide complete backend config so no prompt is needed.","Use `-input=false` in CI and supply all values via config/`-backend-config=`.","In embedded use, wire a UIInput implementation before enabling Input.","Avoid piping stdin into interactive init commands."],"tags":["backend","interactive","input","ui","tty"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}