{"record":{"id":"3d341cb43f4f52ba","repo":"hashicorp/terraform","slug":"unknown-validation-type-v","errorCode":null,"errorMessage":"Unknown validation type: %#v","messagePattern":"Unknown validation type: %#v","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/legacy/helper/schema/schema.go","lineNumber":1559,"sourceCode":"\t\t\t\treturn nil, []error{fmt.Errorf(\"%s (%s): %s\", k, key, err)}\n\t\t\t}\n\t\tcase TypeInt:\n\t\t\tvar n int\n\t\t\tif err := mapstructure.WeakDecode(raw, &n); err != nil {\n\t\t\t\treturn nil, []error{fmt.Errorf(\"%s (%s): %s\", k, key, err)}\n\t\t\t}\n\t\tcase TypeFloat:\n\t\t\tvar n float64\n\t\t\tif err := mapstructure.WeakDecode(raw, &n); err != nil {\n\t\t\t\treturn nil, []error{fmt.Errorf(\"%s (%s): %s\", k, key, err)}\n\t\t\t}\n\t\tcase TypeString:\n\t\t\tvar n string\n\t\t\tif err := mapstructure.WeakDecode(raw, &n); err != nil {\n\t\t\t\treturn nil, []error{fmt.Errorf(\"%s (%s): %s\", k, key, err)}\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"Unknown validation type: %#v\", schema.Type))\n\t\t}\n\t}\n\treturn nil, nil\n}\n\nfunc getValueType(k string, schema *Schema) (ValueType, error) {\n\tif schema.Elem == nil {\n\t\treturn TypeString, nil\n\t}\n\tif vt, ok := schema.Elem.(ValueType); ok {\n\t\treturn vt, nil\n\t}\n\n\t// If a Schema is provided to a Map, we use the Type of that schema\n\t// as the type for each element in the Map.\n\tif s, ok := schema.Elem.(*Schema); ok {\n\t\treturn s.Type, nil\n\t}","sourceCodeStart":1541,"sourceCodeEnd":1577,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/legacy/helper/schema/schema.go#L1541-L1577","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\n\"labels\": { Type: schema.TypeMap, Elem: &schema.Schema{Type: schema.TypeList} },\n// after\n\"labels\": { Type: schema.TypeMap, Elem: &schema.Schema{Type: schema.TypeString} },","handlingStrategy":"validation","validationCode":"func mapElemPrimitive(s *schema.Schema) error {\n    if s.Type != schema.TypeMap { return nil }\n    vt, err := getValueType(s.Type.String(), s) // or replicate logic\n    _ = err\n    switch vt {\n    case schema.TypeBool, schema.TypeInt, schema.TypeFloat, schema.TypeString:\n        return nil\n    }\n    return fmt.Errorf(\"TypeMap element type must be primitive\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["terraform","provider-sdk","schema","map","validation","panic"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}