hashicorp/terraform · error

%s: %s

Error message

%s: %s

What it means

Raised in inputForSchema when an interactive prompt for a required provider/backend attribute fails to read a value. The message is formatted as 'attrName: underlyingError'. inputForSchema walks schema.Attributes for Required+null+primitive attributes and prompts for each; an I/O failure reading the answer produces this.

Source

Thrown at internal/command/meta_config.go:403

	for name, attrS := range schema.Attributes {
		if attrS.Required && retVals[name].IsNull() && attrS.Type.IsPrimitiveType() {
			names = append(names, name)
		}
	}
	sort.Strings(names)

	input := m.UIInput()
	for _, name := range names {
		attrS := schema.Attributes[name]

		for {
			strVal, err := input.Input(context.Background(), &terraform.InputOpts{
				Id:          name,
				Query:       name,
				Description: attrS.Description,
			})
			if err != nil {
				return cty.UnknownVal(schema.ImpliedType()), fmt.Errorf("%s: %s", name, err)
			}

			val := cty.StringVal(strVal)
			val, err = convert.Convert(val, attrS.Type)
			if err != nil {
				m.showDiagnostics(fmt.Errorf("Invalid value: %s", err))
				continue
			}

			retVals[name] = val
			break
		}
	}

	return cty.ObjectVal(retVals), nil
}

// configSources returns the source cache from the receiver's config loader,

View on GitHub (pinned to c9def3e214)

Solutions

  1. Supply all required attributes explicitly in the config so no prompt is needed.
  2. Run with -input=false to fail fast with a clear 'missing required attribute' diagnostic instead of an I/O error.
  3. Keep stdin open / allocate a TTY for interactive runs.
  4. Validate the backend block has all required keys before running init.

Example fix

// before
// backend "s3" block missing 'bucket', init prompts with closed stdin

// after
// fill required attrs in config:
backend "s3" { bucket = "my-bucket" region = "us-east-1" key = "tfstate" }
Defensive patterns

Strategy: validation

Validate before calling

// Provide all required backend/provider attributes in config so no prompt
// is needed. Validate required keys before init.
required := []string{"bucket", "region", "key"}
for _, k := range required {
    if !backendBlock.HasAttribute(k) {
        return fmt.Errorf("missing required backend attribute %s", k)
    }
}

Prevention

When it happens

Trigger: inputForSchema: input.Input(...) returns err!=nil for some required attribute name. Reached during backend/provider config init when required attributes are unset and interactive input is attempted but the reader fails (closed stdin, no TTY).

Common situations: CI/automation running init without -input=false where a required backend attribute is missing; closed stdin during an interactive backend config; terminal disconnect mid-prompt.

Related errors


AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07). Data as JSON: /api/errors/ace4c632cb970b14. Report an issue: GitHub.