{"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":"console","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/c9def3e214014c1188faabfc4a5bde5095139765/internal/command/meta_backend.go#L2701-L2737","documentation":"In Meta.backendInitFromConfig (meta_backend.go:2719), when interactive input is enabled (m.Input()) and required backend arguments are missing, Terraform prompts the user via inputForSchema to fill them in. If that prompting itself fails (e.g. no TTY, EOF on stdin, or a UI input error), this wraps the failure. It is about the INPUT mechanism, not about invalid config values.","triggerScenarios":"Running `terraform init` in a non-interactive context (piped/closed stdin, CI with no TTY) where a backend argument is missing so Terraform tries to prompt and input fails; a custom UI/input implementation returning an error.","commonSituations":"CI pipelines or containers with no TTY where required backend attributes are omitted and -input=true (the default); scripts that close stdin.","solutions":["Provide all required backend arguments in the config or via `-backend-config=` so no prompt is needed.","Run with `-input=false` in non-interactive environments and supply values explicitly.","If you expect a TTY, ensure the terminal/PTY is attached and stdin is open.","Check the wrapped `%s` for the specific input error (EOF, not a terminal)."],"exampleFix":"// before: terraform init   (CI, no TTY; fails: Error asking for input to configure backend)\n// after: terraform init -input=false -backend-config=\"bucket=mybucket\" -backend-config=\"key=prod.tfstate\"","handlingStrategy":"validation","validationCode":"// In non-interactive contexts, ensure no required backend attribute is missing before init.\nfunc backendConfigCompleteForCI(c *configs.Backend) error {\n    if os.Getenv(\"CI\") == \"\" { return nil }\n    // Required: ensure all backend attrs supplied; else pass -input=false with -backend-config.\n    return validateNoMissingAttrs(c)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use `-input=false` in CI and supply all required backend attributes explicitly.","Provide required backend values in config or via `-backend-config=` rather than prompts.","Ensure a TTY is attached when you intend interactive prompting.","Don't pipe/EOF stdin into interactive init."],"tags":["backend","input","init","interactive","ci"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}