hashicorp/terraform · critical
unknown value type in TypeMap %T
Error message
unknown value type in TypeMap %T
What it means
Panics in SerializeValueForHash (serialize.go:64) when hashing a TypeMap value. The inner switch over each map value supports only int, float64, and string; any other concrete Go type (bool, []interface{}, map, struct) panics.
Source
Thrown at internal/legacy/helper/schema/serialize.go:64
sort.Strings(keys)
buf.WriteRune('[')
for _, k := range keys {
innerVal := m[k]
if innerVal == nil {
continue
}
buf.WriteString(k)
buf.WriteRune(':')
switch innerVal := innerVal.(type) {
case int:
buf.WriteString(strconv.Itoa(innerVal))
case float64:
buf.WriteString(strconv.FormatFloat(innerVal, 'g', -1, 64))
case string:
buf.WriteString(innerVal)
default:
panic(fmt.Sprintf("unknown value type in TypeMap %T", innerVal))
}
buf.WriteRune(';')
}
buf.WriteRune(']')
case TypeSet:
buf.WriteRune('{')
s := val.(*Set)
for _, innerVal := range s.List() {
serializeCollectionMemberForHash(buf, innerVal, schema.Elem)
}
buf.WriteRune('}')
default:
panic("unknown schema type to serialize")
}
buf.WriteRune(';')
}
View on GitHub (pinned to c9def3e214)
Solutions
- Ensure map values are limited to string/int/float.
- Coerce booleans to strings ("true"/"false") before they reach the hashing path.
- Avoid nesting lists/objects as direct map values; model them as nested blocks instead.
Example fix
// before
set.Add(map[string]interface{}{"enabled": true})
// after
set.Add(map[string]interface{}{"enabled": "true"}) Defensive patterns
Strategy: validation
Validate before calling
func mapValuesHashable(m map[string]interface{}) error {
for k, v := range m {
switch v.(type) {
case int, float64, string: continue
default: return fmt.Errorf("map key %s has non-hashable value type %T", k, v)
}
}
return nil
} Prevention
- Keep TypeMap values to string/int/float.
- Coerce bools to strings before they reach set hashing.
- Avoid nested objects as direct map values.
When it happens
Trigger: A TypeMap containing a non-{int,float64,string} value (e.g. a bool or a nested structure) that gets hashed because the map is an element of a parent TypeSet.
Common situations: Provider tests or custom code building sets-of-maps with bool/struct values; legacy map values that were not string-coerced before hashing.
Related errors
- unknown schema type to serialize
- invalid element type: %T
- missing field in set: %s.%s
- set item just set doesn't exist
- invalid set element type
AI-assisted analysis of hashicorp/terraform@c9def3e214 (2026-08-07).
Data as JSON: /api/errors/cdddfc72792e5a3f.
Report an issue: GitHub.