{"record":{"id":"65251fdaa40fa46d","repo":"hashicorp/terraform","slug":"unknown-type-v-65251f","errorCode":null,"errorMessage":"Unknown type: %#v","messagePattern":"Unknown type: %#v","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/legacy/helper/schema/field_reader_diff.go","lineNumber":80,"sourceCode":"\t}\n\n\tvar res FieldReadResult\n\tvar err error\n\n\tschema := schemaList[len(schemaList)-1]\n\tswitch schema.Type {\n\tcase TypeBool, TypeInt, TypeFloat, TypeString:\n\t\tres, err = r.readPrimitive(address, schema)\n\tcase TypeList:\n\t\tres, err = readListField(r, address, schema)\n\tcase TypeMap:\n\t\tres, err = r.readMap(address, schema)\n\tcase TypeSet:\n\t\tres, err = r.readSet(address, schema)\n\tcase typeObject:\n\t\tres, err = readObjectField(r, address, schema.Elem.(map[string]*Schema))\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Unknown type: %#v\", schema.Type))\n\t}\n\n\tr.cache[cacheKey] = cachedFieldReadResult{\n\t\tval: res,\n\t\terr: err,\n\t}\n\treturn res, err\n}\n\nfunc (r *DiffFieldReader) readMap(\n\taddress []string, schema *Schema) (FieldReadResult, error) {\n\tresult := make(map[string]interface{})\n\tresultSet := false\n\n\t// First read the map from the underlying source\n\tsource, err := r.Source.ReadField(address)\n\tif err != nil {\n\t\treturn FieldReadResult{}, err","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/legacy/helper/schema/field_reader_diff.go#L62-L98","documentation":"A panic in `DiffFieldReader.readField` (internal/legacy/helper/schema/field_reader_diff.go:80), default branch of the switch over `schema.Type`. The diff-backed reader handles the same type set as the config reader (TypeBool/TypeInt/TypeFloat/TypeString/TypeList/TypeMap/TypeSet/typeObject); any other Type panics with 'Unknown type: %#v'. This path runs when merging a diff against prior state/config, so it is exercised during plan diffing for a malformed schema.","triggerScenarios":"Computing/applying a diff for a provider resource whose schema has an attribute with a Type outside the recognized set. The diff reader dispatches on Type and falls through to the panic.","commonSituations":"Provider schema with an unset/invalid Type; SDK version mismatch; a field whose Type was changed in the provider without a state migration; legacy provider using a custom ValueType unknown to the diff reader.","solutions":["Identify the attribute with the invalid Type in the provider schema and set a valid ValueType.","Add provider schema validation tests to fail fast on TypeInvalid.","Pin SDK and provider versions consistently.","If a Type was renamed/removed, add a state migration so old state never reaches the new reader with the old Type."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"// Go (provider): validate schema Types the diff 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(\"diff reader cannot handle schema %q Type %d\", name, s.Type)\n    }\n}","typeGuard":"// Go: confirm a Type is diff-reader-compatible\nfunc diffReadableType(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 the diff path touches.","Add a state migration whenever a field Type changes so old diffs stay consistent.","Pin provider versions across plan and apply to keep set/schema hashing stable.","Add provider schema tests that fail on TypeInvalid."],"tags":["terraform","provider-sdk","legacy-schema","field-reader","diff-reader","panic","schema-type","provider-bug"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}