hashicorp/terraform · warning

Invalid value: %s

Error message

Invalid value: %s

What it means

Raised in inputForSchema when the user-supplied string for a required attribute cannot be converted to the attribute's declared type (e.g. non-numeric string into a number attribute, or malformed bool). The prompt loop re-displays this diagnostic and re-prompts rather than aborting; it is shown interactively, not returned as a fatal error.

Source

Thrown at internal/command/meta_config.go:409

	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,
// which the caller must not modify.
//
// If a config loader has not yet been instantiated then no files could have
// been loaded already, so this method returns a nil map in that case.
func (m *Meta) configSources() map[string][]byte {
	if m.configLoader == nil {

View on GitHub (pinned to c9def3e214)

Solutions

  1. Re-enter a value of the correct type at the re-prompt (true/false for bool, a valid number for number, etc.).
  2. Check the attribute's schema/type in the provider/backend docs before answering.
  3. Set the attribute in the config file directly to avoid the interactive guess.
  4. Use -input=false and supply values in config for type safety.

Example fix

// before
// prompt for 'encrypt' (bool): user types 'yes' -> Invalid value

// after
// prompt for 'encrypt': user types 'true'
Defensive patterns

Strategy: validation

Validate before calling

// Type-check the value before submitting it at a prompt
func coerce(attrType cty.Type, s string) (cty.Value, error) {
    return convert.Convert(cty.StringVal(s), attrType)
}
// e.g. for bool: only 'true'/'false' pass; for number: valid numeric strings.

Type guard

func isValidForType(s string, t cty.Type) bool {
    _, err := convert.Convert(cty.StringVal(s), t)
    return err == nil
}

Prevention

When it happens

Trigger: inputForSchema: convert.Convert(cty.StringVal(strVal), attrS.Type) returns err!=nil, so m.showDiagnostics(fmt.Errorf("Invalid value: %s", err)) is printed and the loop continues. Example: typing 'abc' for a number attribute, or 'tru' for a bool.

Common situations: User typos a boolean (tru/1/yes instead of true); user enters text for a numeric field; user enters a non-URL for a URL-typed attr; confusion about the expected type at a prompt.

Related errors


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