hashicorp/terraform · critical
Unknown validation type: %#v
Error message
Unknown validation type: %#v
What it means
Panics in validateMapValues (schema.go:1559) which validates each value of a TypeMap against the element type derived from schema.Elem via getValueType. The switch only handles TypeBool/TypeInt/TypeFloat/TypeString; a non-primitive element type hits the default and panics.
Source
Thrown at internal/legacy/helper/schema/schema.go:1559
return nil, []error{fmt.Errorf("%s (%s): %s", k, key, err)}
}
case TypeInt:
var n int
if err := mapstructure.WeakDecode(raw, &n); err != nil {
return nil, []error{fmt.Errorf("%s (%s): %s", k, key, err)}
}
case TypeFloat:
var n float64
if err := mapstructure.WeakDecode(raw, &n); err != nil {
return nil, []error{fmt.Errorf("%s (%s): %s", k, key, err)}
}
case TypeString:
var n string
if err := mapstructure.WeakDecode(raw, &n); err != nil {
return nil, []error{fmt.Errorf("%s (%s): %s", k, key, err)}
}
default:
panic(fmt.Sprintf("Unknown validation type: %#v", schema.Type))
}
}
return nil, nil
}
func getValueType(k string, schema *Schema) (ValueType, error) {
if schema.Elem == nil {
return TypeString, nil
}
if vt, ok := schema.Elem.(ValueType); ok {
return vt, nil
}
// If a Schema is provided to a Map, we use the Type of that schema
// as the type for each element in the Map.
if s, ok := schema.Elem.(*Schema); ok {
return s.Type, nil
}View on GitHub (pinned to c9def3e214)
Solutions
- Use a primitive element type for TypeMap (String/Int/Float/Bool).
- For maps of objects, restructure as a TypeSet or TypeList of nested blocks/objects.
- If nested map values are required, model them as a nested block (NestedBlock / Elem *Resource).
Example fix
// before
"labels": { Type: schema.TypeMap, Elem: &schema.Schema{Type: schema.TypeList} },
// after
"labels": { Type: schema.TypeMap, Elem: &schema.Schema{Type: schema.TypeString} }, Defensive patterns
Strategy: validation
Validate before calling
func mapElemPrimitive(s *schema.Schema) error {
if s.Type != schema.TypeMap { return nil }
vt, err := getValueType(s.Type.String(), s) // or replicate logic
_ = err
switch vt {
case schema.TypeBool, schema.TypeInt, schema.TypeFloat, schema.TypeString:
return nil
}
return fmt.Errorf("TypeMap element type must be primitive")
} Prevention
- Use only primitive element types for TypeMap.
- Model maps-of-objects as a nested block / TypeSet of objects.
- Test the schema with realistic config values.
When it happens
Trigger: A TypeMap schema whose Elem resolves to a non-primitive ValueType (TypeList/TypeMap/TypeSet/typeObject/TypeInvalid), then the config supplies map values so validateMapValues runs during plan/apply.
Common situations: Provider authors attempt a 'map of lists/objects' via `Elem: &schema.Schema{Type: schema.TypeList}` (unsupported in the legacy SDK) or set an object/invalid element type on a TypeMap.
Related errors
- Unknown type: %#v
- invalid set element type
- unknown value type in TypeMap %T
- invalid collection type
- invalid Schema.Type %s
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/3d341cb43f4f52ba.
Report an issue: GitHub.