{"record":{"id":"0c58827b6853eca0","repo":"hashicorp/terraform","slug":"invalid-value-s","errorCode":null,"errorMessage":"Invalid value: %s","messagePattern":"Invalid value: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/command/meta_config.go","lineNumber":409,"sourceCode":"\n\tinput := m.UIInput()\n\tfor _, name := range names {\n\t\tattrS := schema.Attributes[name]\n\n\t\tfor {\n\t\t\tstrVal, err := input.Input(context.Background(), &terraform.InputOpts{\n\t\t\t\tId:          name,\n\t\t\t\tQuery:       name,\n\t\t\t\tDescription: attrS.Description,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn cty.UnknownVal(schema.ImpliedType()), fmt.Errorf(\"%s: %s\", name, err)\n\t\t\t}\n\n\t\t\tval := cty.StringVal(strVal)\n\t\t\tval, err = convert.Convert(val, attrS.Type)\n\t\t\tif err != nil {\n\t\t\t\tm.showDiagnostics(fmt.Errorf(\"Invalid value: %s\", err))\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tretVals[name] = val\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn cty.ObjectVal(retVals), nil\n}\n\n// configSources returns the source cache from the receiver's config loader,\n// which the caller must not modify.\n//\n// If a config loader has not yet been instantiated then no files could have\n// been loaded already, so this method returns a nil map in that case.\nfunc (m *Meta) configSources() map[string][]byte {\n\tif m.configLoader == nil {","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/command/meta_config.go#L391-L427","documentation":"Thrown during interactive (UI) prompting for a required provider/resource attribute that the user left unset. Meta.inputForSchema reads a raw string from UIInput, wraps it as cty.StringVal, then convert.Convert attempts to coerce it to the attribute's declared type (number, bool, list, etc.). On failure the offending value is surfaced as a diagnostic and the prompt loops, so this is a recoverable per-attempt warning rather than a fatal error. It exists because the CLI cannot statically know whether a typed-in string will parse until conversion is attempted.","triggerScenarios":"Meta.inputForSchema is called for an attribute where attrS.Required is true, the given value is null, and attrS.Type.IsPrimitiveType(). The user answers the InputOpts prompt with a value that convert.Convert(val, attrS.Type) rejects (e.g. 'abc' for a number attribute, 'yes' for a bool, malformed input for a type that is not cty.String).","commonSituations":"Running terraform plan/apply without -var or var files for variables backed by required provider attributes; CI shells that accidentally feed interactive stdin; supplying a value like 'true'/'false' where a number is required; pasting values with stray whitespace or quotes.","solutions":["Re-enter the value at the prompt in the correct primitive type (a bare number like 5, or true/false for bool).","Pre-supply the value non-interactively with -var or a *.tfvars file / TF_VAR_* environment variable so the attribute is no longer null and inputForSchema skips prompting.","If automating, provide all required inputs via -input=false plus -var/-var-file to avoid the prompt entirely.","Check the attribute's declared type in the provider schema (terraform providers schema -json) and match the literal syntax exactly."],"exampleFix":"// before: prompted for a number attribute, typed 'abc'\n// after: supply via var file\ncount = 3\n// or on CLI\nterraform apply -var=\"replicas=3\" -input=false","handlingStrategy":"validation","validationCode":"// Validate the raw string against the attribute type before submitting.\nfunc parsePrimitive(raw string, t cty.Type) (cty.Value, error) {\n    v := cty.StringVal(raw)\n    return convert.Convert(v, t) // returns err identical to the CLI path\n}\n// caller:\nif _, err := parsePrimitive(input, attrS.Type); err != nil {\n    log.Printf(\"please re-enter a valid %s\", attrS.Type.FriendlyName())\n}","typeGuard":"// guard before prompting: only primitive types are promptable\nfunc isPromptable(attrS *configschema.Attribute) bool {\n    return attrS.Required && attrS.Type.IsPrimitiveType()\n}","tryCatchPattern":null,"preventionTips":["Pre-supply all required variables via -var / *.tfvars / TF_VAR_* so inputForSchema never prompts.","Run non-interactive CI with -input=false to fail fast on missing values instead of looping.","Validate configurations with terraform validate before plan/apply."],"tags":["terraform","interactive-input","config","type-conversion","cli"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}