{"record":{"id":"3f7fe502f665b35c","repo":"hashicorp/terraform","slug":"unknown-type-s-3f7fe5","errorCode":null,"errorMessage":"Unknown type: %s","messagePattern":"Unknown type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/legacy/helper/schema/field_reader_map.go","lineNumber":38,"sourceCode":"\tschemaList := addrToSchema(address, r.Schema)\n\tif len(schemaList) == 0 {\n\t\treturn FieldReadResult{}, nil\n\t}\n\n\tschema := schemaList[len(schemaList)-1]\n\tswitch schema.Type {\n\tcase TypeBool, TypeInt, TypeFloat, TypeString:\n\t\treturn r.readPrimitive(address, schema)\n\tcase TypeList:\n\t\treturn readListField(r, address, schema)\n\tcase TypeMap:\n\t\treturn r.readMap(k, schema)\n\tcase TypeSet:\n\t\treturn r.readSet(address, schema)\n\tcase typeObject:\n\t\treturn readObjectField(r, address, schema.Elem.(map[string]*Schema))\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Unknown type: %s\", schema.Type))\n\t}\n}\n\nfunc (r *MapFieldReader) readMap(k string, schema *Schema) (FieldReadResult, error) {\n\tresult := make(map[string]interface{})\n\tresultSet := false\n\n\t// If the name of the map field is directly in the map with an\n\t// empty string, it means that the map is being deleted, so mark\n\t// that is is set.\n\tif v, ok := r.Map.Access(k); ok && v == \"\" {\n\t\tresultSet = true\n\t}\n\n\tprefix := k + \".\"\n\tr.Map.Range(func(k, v string) bool {\n\t\tif strings.HasPrefix(k, prefix) {\n\t\t\tresultSet = true","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/legacy/helper/schema/field_reader_map.go#L20-L56","documentation":"A panic in `MapFieldReader.ReadField` (internal/legacy/helper/schema/field_reader_map.go:38), default branch of the switch over `schema.Type`. The flat-map-backed reader dispatches TypeBool/TypeInt/TypeFloat/TypeString/TypeList/TypeMap/TypeSet/typeObject; any other Type panics with 'Unknown type: %s'. This reader is used when a schema is read from a flat key/value map source (e.g. raw state attributes), so the panic reflects a malformed provider schema Type encountered during map-source reads.","triggerScenarios":"Reading a field from a flat map source (KV state attributes) when the schema attribute's Type is outside the recognized ValueType set — unset (TypeInvalid) or an unknown constant.","commonSituations":"Provider schema with an unset/invalid Type; SDK version drift; reading legacy flat-map state for a field whose schema Type is not a known scalar/collection/object constant.","solutions":["Audit the provider schema and set a valid Type on every attribute.","Add provider schema-construction tests asserting no TypeInvalid entries.","Keep SDK and provider versions in sync.","If migrating schemas, ensure old flat-map state fields map to attributes with valid Types."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"// Go (provider): validate schema Types the map reader will encounter\nfor name, s := range resource.Schema {\n    switch s.Type {\n    case schema.TypeString, schema.TypeBool, schema.TypeInt, schema.TypeFloat,\n         schema.TypeList, schema.TypeMap, schema.TypeSet:\n    default:\n        return fmt.Errorf(\"map reader cannot handle schema %q Type %d\", name, s.Type)\n    }\n}","typeGuard":"// Go: confirm a Type is map-reader-compatible\nfunc mapReadableType(t schema.ValueType) bool {\n    switch t {\n    case schema.TypeString, schema.TypeBool, schema.TypeInt, schema.TypeFloat,\n         schema.TypeList, schema.TypeMap, schema.TypeSet:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Set a valid Type on every schema attribute read from flat-map state.","Add schema self-tests rejecting TypeInvalid entries.","Keep SDK and provider versions consistent.","Ensure legacy flat-map state fields map to attributes with valid Types after migrations."],"tags":["terraform","provider-sdk","legacy-schema","field-reader","map-reader","panic","schema-type","provider-bug"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}