{"record":{"id":"cdddfc72792e5a3f","repo":"hashicorp/terraform","slug":"unknown-value-type-in-typemap-t","errorCode":null,"errorMessage":"unknown value type in TypeMap %T","messagePattern":"unknown value type in TypeMap %T","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/legacy/helper/schema/serialize.go","lineNumber":64,"sourceCode":"\t\tsort.Strings(keys)\n\t\tbuf.WriteRune('[')\n\t\tfor _, k := range keys {\n\t\t\tinnerVal := m[k]\n\t\t\tif innerVal == nil {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tbuf.WriteString(k)\n\t\t\tbuf.WriteRune(':')\n\n\t\t\tswitch innerVal := innerVal.(type) {\n\t\t\tcase int:\n\t\t\t\tbuf.WriteString(strconv.Itoa(innerVal))\n\t\t\tcase float64:\n\t\t\t\tbuf.WriteString(strconv.FormatFloat(innerVal, 'g', -1, 64))\n\t\t\tcase string:\n\t\t\t\tbuf.WriteString(innerVal)\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Sprintf(\"unknown value type in TypeMap %T\", innerVal))\n\t\t\t}\n\n\t\t\tbuf.WriteRune(';')\n\t\t}\n\t\tbuf.WriteRune(']')\n\tcase TypeSet:\n\t\tbuf.WriteRune('{')\n\t\ts := val.(*Set)\n\t\tfor _, innerVal := range s.List() {\n\t\t\tserializeCollectionMemberForHash(buf, innerVal, schema.Elem)\n\t\t}\n\t\tbuf.WriteRune('}')\n\tdefault:\n\t\tpanic(\"unknown schema type to serialize\")\n\t}\n\tbuf.WriteRune(';')\n}\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/legacy/helper/schema/serialize.go#L46-L82","documentation":"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.","triggerScenarios":"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.","commonSituations":"Provider tests or custom code building sets-of-maps with bool/struct values; legacy map values that were not string-coerced before hashing.","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."],"exampleFix":"// before\nset.Add(map[string]interface{}{\"enabled\": true})\n// after\nset.Add(map[string]interface{}{\"enabled\": \"true\"})","handlingStrategy":"validation","validationCode":"func mapValuesHashable(m map[string]interface{}) error {\n    for k, v := range m {\n        switch v.(type) {\n        case int, float64, string: continue\n        default: return fmt.Errorf(\"map key %s has non-hashable value type %T\", k, v)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep TypeMap values to string/int/float.","Coerce bools to strings before they reach set hashing.","Avoid nested objects as direct map values."],"tags":["terraform","schema","set","map","hashing","panic"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}