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
- Re-enter a value of the correct type at the re-prompt (true/false for bool, a valid number for number, etc.).
- Check the attribute's schema/type in the provider/backend docs before answering.
- Set the attribute in the config file directly to avoid the interactive guess.
- 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
- Enter values matching the attribute type (true/false, valid numbers, URLs).
- Set typed values directly in config to avoid interactive guessing.
- Use -input=false and supply all values in config.
- Consult provider docs for each attribute's expected type.
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
- %s: %s
- invalid value for %q: %s
- invalid value for %q: must be a number
- The -upgrade flag conflicts with -lockfile=readonly.
- credentials file %s has invalid value for "credentials" prop
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/0c58827b6853eca0.
Report an issue: GitHub.