{"record":{"id":"9967d88ce36c74b8","repo":"hashicorp/terraform","slug":"unknown-schema-type-to-serialize","errorCode":null,"errorMessage":"unknown schema type to serialize","messagePattern":"unknown schema type to serialize","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/legacy/helper/schema/serialize.go","lineNumber":78,"sourceCode":"\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\n// SerializeValueForHash appends a serialization of the given resource config\n// to the given buffer, guaranteeing deterministic results given the same value\n// and schema.\n//\n// Its primary purpose is as input into a hashing function in order\n// to hash complex substructures when used in sets, and so the serialization\n// is not reversible.\nfunc SerializeResourceForHash(buf *bytes.Buffer, val interface{}, resource *Resource) {\n\tif val == nil {\n\t\treturn\n\t}\n\tsm := resource.Schema\n\tm := val.(map[string]interface{})\n\tvar keys []string","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/legacy/helper/schema/serialize.go#L60-L96","documentation":"Panics in SerializeValueForHash (serialize.go:78) default branch. The outer switch serializes by schema.Type and only handles the defined ValueType constants; an uninitialized or out-of-range Type (e.g. TypeInvalid) panics.","triggerScenarios":"A schema element that is part of a TypeSet being hashed, whose Type is TypeInvalid or an unknown constant.","commonSituations":"Same root cause as 981/986: a schema entry missing Type, used inside a set so it reaches the hashing serializer.","solutions":["Set schema.Type to a defined constant on every schema reachable from a TypeSet.","Add a schema validation pass asserting Type != TypeInvalid before exercising set hashing."],"exampleFix":"// before\n\"items\": { Type: schema.TypeSet, Elem: &schema.Schema{} },\n// after\n\"items\": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString} },","handlingStrategy":"type-guard","validationCode":"for _, s := range schemaReachableFromSets(r) {\n    if !knownValueType(s.Type) { return fmt.Errorf(\"set element has unknown Type\") }\n}","typeGuard":"func knownValueType(t schema.ValueType) bool {\n    switch t {\n    case schema.TypeBool, schema.TypeInt, schema.TypeFloat, schema.TypeString,\n        schema.TypeList, schema.TypeMap, schema.TypeSet:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Set Type on every schema reachable from a TypeSet.","Self-test schemas before exercising set hashing."],"tags":["terraform","schema","set","hashing","panic"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}