{"record":{"id":"522683e303acd626","repo":"opentofu/opentofu","slug":"error-asking-for-input-to-configure-backend-q-w","errorCode":null,"errorMessage":"Error asking for input to configure backend %q: %w","messagePattern":"Error asking for input to configure backend %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/command/meta_backend.go","lineNumber":1447,"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 `tofu` 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, view)\n\t\tif err != nil {\n\t\t\tdiags = diags.Append(fmt.Errorf(\"Error asking for input to configure backend %q: %w\", canonType, 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(ctx, newVal)\n\tdiags = diags.Append(configureDiags.InConfigBody(c.Config, \"\"))","sourceCodeStart":1429,"sourceCodeEnd":1465,"githubUrl":"https://github.com/opentofu/opentofu/blob/3561785c48c1ce615e7c50261bd351f26053efa2/internal/command/meta_backend.go#L1429-L1465","documentation":"When interactive input is enabled (m.Input()) and the backend block leaves required attributes unset, backendInitFromConfig prompts for each missing value via m.inputForSchema (meta_backend.go:1447). This error wraps any failure of that prompting round — EOF on closed stdin, no TTY, or a cancelled prompt — not a validation failure of the values themselves. The diagnostic is appended (init then continues and fails with it), so nothing is half-configured.","triggerScenarios":"`tofu init` with a required backend attribute missing while m.Input() is true but the prompt cannot complete: stdin closed (`tofu init < /dev/null`), non-TTY CI without a pty, ssh -T, or the user aborting with Ctrl-C at the backend attribute prompt.","commonSituations":"CI pipelines forgetting -input=false; scripts piping commands without a pty; scheduled/cron tasks with no controlling terminal; a single forgotten attribute (bucket, region, conn_str) triggering the prompt in automation.","solutions":["Provide every required backend attribute — in the `backend` block or via repeatable `-backend-config=\"key=value\"` — so no prompt is needed","In automation always run `tofu init -input=false`; missing values then fail as explicit config validation errors instead of prompt errors","When interactive input is intended, run in a real TTY with stdin open (or wrap tofu in a pty)","If aborted mid-prompt, just re-run init; no state was modified"],"exampleFix":"# before: CI closes stdin, required attribute missing\n$ tofu init < /dev/null\nError: Error asking for input to configure backend \"s3\": EOF\n\n# after: input disabled and values supplied explicitly\n$ tofu init -input=false \\\n    -backend-config=\"bucket=tfstate-prod\" \\\n    -backend-config=\"key=env/terraform.tfstate\" \\\n    -backend-config=\"region=us-east-1\"","handlingStrategy":"validation","validationCode":"// Pre-flight: every required backend attribute must be set before non-interactive init.\ncfg := parseBackendBlock(\"main.tf\")     // hclparse/configs loader\nfor _, name := range requiredAttrsForBackend(cfg.Type) { // from backend docs/schema\n    if !cfg.HasAttr(name) && !backendConfigOverrides.Has(name) {\n        return fmt.Errorf(\"backend %q missing required attribute %q\", cfg.Type, name)\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass `-input=false` in automation and supply all required backend attributes explicitly","Keep a complete backend block in version control; use -backend-config files for environment-specific values","When you must drive prompts programmatically, allocate a pty (terraform-exec style)"],"tags":["opentofu","interactive","prompt","stdin","ci","backend-config"],"backgroundTag":null,"analyzedSha":"3561785c48c1ce615e7c50261bd351f26053efa2","analyzedAt":"2026-08-15T23:27:16.226Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}