{"record":{"id":"0ed1ed41c11ca1ff","repo":"hashicorp/terraform","slug":"unknown-type-v-0ed1ed","errorCode":null,"errorMessage":"Unknown type: %#v","messagePattern":"Unknown type: %#v","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/legacy/helper/schema/field_writer_map.go","lineNumber":114,"sourceCode":"\tschemaList := addrToSchema(addr, w.Schema)\n\tif len(schemaList) == 0 {\n\t\treturn fmt.Errorf(\"Invalid address to set: %#v\", addr)\n\t}\n\n\tschema := schemaList[len(schemaList)-1]\n\tswitch schema.Type {\n\tcase TypeBool, TypeInt, TypeFloat, TypeString:\n\t\treturn w.setPrimitive(addr, value, schema)\n\tcase TypeList:\n\t\treturn w.setList(addr, value, schema)\n\tcase TypeMap:\n\t\treturn w.setMap(addr, value, schema)\n\tcase TypeSet:\n\t\treturn w.setSet(addr, value, schema)\n\tcase typeObject:\n\t\treturn w.setObject(addr, value, schema)\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Unknown type: %#v\", schema.Type))\n\t}\n}\n\nfunc (w *MapFieldWriter) setList(\n\taddr []string,\n\tv interface{},\n\tschema *Schema) error {\n\tk := strings.Join(addr, \".\")\n\tsetElement := func(idx string, value interface{}) error {\n\t\taddrCopy := make([]string, len(addr), len(addr)+1)\n\t\tcopy(addrCopy, addr)\n\t\treturn w.set(append(addrCopy, idx), value)\n\t}\n\n\tvar vs []interface{}\n\tif err := mapstructure.Decode(v, &vs); err != nil {\n\t\treturn fmt.Errorf(\"%s: %s\", k, err)\n\t}","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/legacy/helper/schema/field_writer_map.go#L96-L132","documentation":"Panics in MapFieldWriter.set (internal/legacy/helper/schema/field_writer_map.go:114). The switch over schema.Type handles TypeBool/TypeInt/TypeFloat/TypeString/TypeList/TypeMap/TypeSet/typeObject; the default branch panics, meaning schema.Type is not a recognized ValueType constant (most often TypeInvalid/0 because Type was never set).","triggerScenarios":"Writing a field whose Schema has an unset or out-of-range Type (TypeInvalid), e.g. a provider schema entry missing the Type field, or a dynamically-built schema with an uninitialized Type. WriteField -> set -> default panic.","commonSituations":"Provider authors forgetting `Type:` on a schema entry, copy-paste mistakes, or schema maps assembled via reflection/composition that leave Type at its zero value.","solutions":["Set Type on every Schema entry to one of the schema.Type* constants.","Add a schema-validation pass in provider tests (or a Test() on each Resource) that asserts Type != TypeInvalid before exercising WriteField.","Search the resource's Schema map for any entry with Type == 0."],"exampleFix":"// before\n\"tags\": { Elem: &schema.Schema{Type: schema.TypeString} },\n// after\n\"tags\": { Type: schema.TypeMap, Elem: &schema.Schema{Type: schema.TypeString} },","handlingStrategy":"validation","validationCode":"func validValueType(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}\n// assert before WriteField\nfor k, s := range resource.Schema {\n    if !validValueType(s.Type) { panic(\"invalid Type on \" + k) }\n}","typeGuard":"func schemaTypeIsKnown(s *schema.Schema) bool { return s.Type != schema.TypeInvalid }","tryCatchPattern":null,"preventionTips":["Always set Type: on every schema entry.","Add a provider schema self-test in TestProvider_Validate.","Lint for schema entries with Type == 0."],"tags":["terraform","provider-sdk","schema","type","panic"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}