{"record":{"id":"a60aca00835d7037","repo":"hashicorp/terraform","slug":"unknown-type-s","errorCode":null,"errorMessage":"Unknown type: %s","messagePattern":"Unknown type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/legacy/helper/schema/field_reader.go","lineNumber":342,"sourceCode":"\tcase TypeInt:\n\t\tif value == \"\" {\n\t\t\treturnVal = 0\n\t\t\tbreak\n\t\t}\n\t\tif computed {\n\t\t\tbreak\n\t\t}\n\n\t\tv, err := strconv.ParseInt(value, 0, 0)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturnVal = int(v)\n\tcase TypeString:\n\t\treturnVal = value\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Unknown type: %s\", schema.Type))\n\t}\n\n\treturn returnVal, nil\n}\n","sourceCodeStart":324,"sourceCodeEnd":347,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/legacy/helper/schema/field_reader.go#L324-L347","documentation":"A panic in `MapFieldReader`-style `readPrimitive` (internal/legacy/helper/schema/field_reader.go:342), default branch when `schema.Type` is not TypeBool/TypeInt/TypeFloat/TypeString. The primitive reader only decodes scalar types, so any other (or invalid) Type reaches the panic with 'Unknown type: %s'. Like 973 this reflects a malformed provider schema, but specifically in the legacy map-backed field-reading path.","triggerScenarios":"Terraform reads a primitive field value through the legacy map field reader for a schema attribute whose `Type` is a collection/invalid type rather than a scalar, or whose Type is unset. The reader dispatches scalars to readPrimitive and the bad type falls into the default panic.","commonSituations":"Provider schema with a field declared as a primitive in one place but a collection elsewhere; TypeInvalid from an unset Type; mismatched schema across SDK versions; reading state/config via legacy paths for a field the schema no longer describes as scalar.","solutions":["Audit the provider schema: every field the legacy reader treats as primitive must have Type in {TypeBool, TypeInt, TypeFloat, TypeString}.","Set or correct the `Type` on the offending attribute.","Add provider schema-construction tests to catch TypeInvalid before release.","Reproduce with the provider in isolation to identify the specific attribute, then report/fix in the provider."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"// Go (provider): validate scalar schema types are primitive before read\nfor name, s := range resource.Schema {\n    if isPrimitiveRead(s) {\n        switch s.Type {\n        case schema.TypeString, schema.TypeBool, schema.TypeInt, schema.TypeFloat:\n        default:\n            return fmt.Errorf(\"field %q routed to primitive reader has non-scalar Type %d\", name, s.Type)\n        }\n    }\n}","typeGuard":"// Go: confirm a Type is a primitive scalar\nfunc isScalarType(t schema.ValueType) bool {\n    switch t { case schema.TypeString, schema.TypeBool, schema.TypeInt, schema.TypeFloat: return true }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Ensure every field read as a primitive has a scalar Type set.","Add provider schema tests asserting Types are valid before release.","Avoid declaring a field as scalar in one place and collection elsewhere.","Pin SDK versions consistently."],"tags":["terraform","provider-sdk","legacy-schema","field-reader","panic","schema-type","provider-bug"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}