{"record":{"id":"996e9567ab48cf3a","repo":"hashicorp/terraform","slug":"invalid-schema-type-s","errorCode":null,"errorMessage":"invalid Schema.Type %s","messagePattern":"invalid Schema\\.Type (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/legacy/helper/schema/core_schema.go","lineNumber":227,"sourceCode":"\t\t\t}\n\t\t\t// Some pre-existing schemas assume string as default, so we need\n\t\t\t// to be compatible with them.\n\t\t\telemType = cty.String\n\t\t}\n\t\tswitch s.Type {\n\t\tcase TypeList:\n\t\t\treturn cty.List(elemType)\n\t\tcase TypeSet:\n\t\t\treturn cty.Set(elemType)\n\t\tcase TypeMap:\n\t\t\treturn cty.Map(elemType)\n\t\tdefault:\n\t\t\t// can never get here in practice, due to the case we're inside\n\t\t\tpanic(\"invalid collection type\")\n\t\t}\n\tdefault:\n\t\t// should never happen for a valid schema\n\t\tpanic(fmt.Errorf(\"invalid Schema.Type %s\", s.Type))\n\t}\n}\n\n// CoreConfigSchema is a convenient shortcut for calling CoreConfigSchema on\n// the resource's schema. CoreConfigSchema adds the implicitly required \"id\"\n// attribute for top level resources if it doesn't exist.\nfunc (r *Resource) CoreConfigSchema() *configschema.Block {\n\tblock := r.coreConfigSchema()\n\n\tif block.Attributes == nil {\n\t\tblock.Attributes = map[string]*configschema.Attribute{}\n\t}\n\n\t// Add the implicitly required \"id\" field if it doesn't exist\n\tif block.Attributes[\"id\"] == nil {\n\t\tblock.Attributes[\"id\"] = &configschema.Attribute{\n\t\t\tType:     cty.String,\n\t\t\tOptional: true,","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/legacy/helper/schema/core_schema.go#L209-L245","documentation":"A panic in `Schema.coreConfigSchemaType` (internal/legacy/helper/schema/core_schema.go:227), the default of the OUTER switch over `s.Type`. If a schema's `Type` is not one of TypeString, TypeBool, TypeInt, TypeFloat, TypeList, TypeSet, or TypeMap, it panics with 'invalid Schema.Type %s'. This is a provider-author bug: the schema declared a Type value outside the valid ValueType enumeration (e.g. the zero value `TypeInvalid`, or an undefined constant).","triggerScenarios":"A provider resource or data source schema has a field whose `Type` is left unset (defaults to zero value / TypeInvalid) or set to an invalid constant. Terraform panics the first time it converts that schema to a core configschema type (during plan/apply/schema rendering).","commonSituations":"Provider author forgot to set `Type` on a `*Schema` entry; copy-paste error; a field with only `Computed`/`Optional` but no `Type`; upgrading an SDK where a ValueType constant was removed or renamed.","solutions":["Inspect the provider's schema map for any entry missing an explicit, valid `Type` (TypeString/TypeBool/TypeInt/TypeFloat/TypeList/TypeSet/TypeMap).","Set the `Type` field on the offending schema attribute.","Add a unit test in the provider that builds the schema and asserts no TypeInvalid entries.","Upgrade the provider SDK to a version whose ValueType set matches the code."],"exampleFix":"// before: Type left unset (zero value)\n\"tags\": &schema.Schema{\n    Optional: true,\n}\n\n// after: explicit Type\n\"tags\": &schema.Schema{\n    Type:     schema.TypeMap,\n    Optional: true,\n    Elem:     &schema.Schema{Type: schema.TypeString},\n}","handlingStrategy":"validation","validationCode":"// Go (provider): fail fast if any schema attribute has an invalid Type\nfor name, s := range resource.Schema {\n    switch s.Type {\n    case schema.TypeString, schema.TypeBool, schema.TypeInt, schema.TypeFloat,\n         schema.TypeList, schema.TypeSet, schema.TypeMap:\n    default:\n        return fmt.Errorf(\"schema %q has invalid Type %d\", name, s.Type)\n    }\n}","typeGuard":"// Go: type guard for a valid ValueType\nfunc validSchemaType(s *schema.Schema) bool {\n    switch s.Type {\n    case schema.TypeString, schema.TypeBool, schema.TypeInt, schema.TypeFloat,\n         schema.TypeList, schema.TypeSet, schema.TypeMap:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Always set an explicit, valid `Type` on every *Schema entry.","Add a provider schema-construction unit test that rejects TypeInvalid.","Keep SDK versions in sync with schema code.","Lint schema definitions for missing Type fields."],"tags":["terraform","provider-sdk","legacy-schema","panic","schema-type","provider-bug"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}