{"record":{"id":"dbb32cb87e6b1450","repo":"hashicorp/terraform","slug":"invalid-element-type-t","errorCode":null,"errorMessage":"invalid element type: %T","messagePattern":"invalid element type: %T","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/legacy/helper/schema/serialize.go","lineNumber":126,"sourceCode":"\t\t}\n\n\t\tbuf.WriteString(k)\n\t\tbuf.WriteRune(':')\n\t\tinnerVal := m[k]\n\t\tSerializeValueForHash(buf, innerVal, innerSchema)\n\t}\n}\n\nfunc serializeCollectionMemberForHash(buf *bytes.Buffer, val interface{}, elem interface{}) {\n\tswitch tElem := elem.(type) {\n\tcase *Schema:\n\t\tSerializeValueForHash(buf, val, tElem)\n\tcase *Resource:\n\t\tbuf.WriteRune('<')\n\t\tSerializeResourceForHash(buf, val, tElem)\n\t\tbuf.WriteString(\">;\")\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"invalid element type: %T\", tElem))\n\t}\n}\n","sourceCodeStart":108,"sourceCodeEnd":129,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/legacy/helper/schema/serialize.go#L108-L129","documentation":"Panics in serializeCollectionMemberForHash (serialize.go:126). When hashing a list/set member, it requires the Elem to be *Schema or *Resource; any other concrete type (nil, a ValueType, a plain struct) panics with 'invalid element type: %T'.","triggerScenarios":"A TypeList/TypeSet whose Elem is nil or a non-Schema/non-Resource value, used as a member of a parent TypeSet that is being hashed.","commonSituations":"Provider schema bugs: Elem set to a bare ValueType (schema.TypeString) or a plain struct instead of &schema.Schema/&schema.Resource.","solutions":["Set Elem to &schema.Schema{...} or &schema.Resource{...} on every list/set.","Lint schemas for collections whose Elem is not *Schema/*Resource."],"exampleFix":"// before\n\"rules\": { Type: schema.TypeSet, Elem: schema.TypeString },\n// after\n\"rules\": { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString} },","handlingStrategy":"type-guard","validationCode":"func collectionElemOk(s *schema.Schema) bool {\n    if s.Type != schema.TypeList && s.Type != schema.TypeSet { return true }\n    switch s.Elem.(type) {\n    case *schema.Schema, *schema.Resource: return true\n    }\n    return false\n}","typeGuard":"func isSchemaOrResource(v interface{}) bool {\n    switch v.(type) {\n    case *schema.Schema, *schema.Resource: return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Set Elem to &schema.Schema or &schema.Resource on every list/set.","Lint collections for invalid Elem types."],"tags":["terraform","schema","set","hashing","panic"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}