{"record":{"id":"b58a7405eccbfd65","repo":"hashicorp/terraform","slug":"unknown-type-s-b58a74","errorCode":null,"errorMessage":"unknown type %s","messagePattern":"unknown type (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/legacy/helper/schema/schema.go","lineNumber":1777,"sourceCode":"\t\treturn nil\n\tcase TypeBool:\n\t\treturn false\n\tcase TypeInt:\n\t\treturn 0\n\tcase TypeFloat:\n\t\treturn 0.0\n\tcase TypeString:\n\t\treturn \"\"\n\tcase TypeList:\n\t\treturn []interface{}{}\n\tcase TypeMap:\n\t\treturn map[string]interface{}{}\n\tcase TypeSet:\n\t\treturn new(Set)\n\tcase typeObject:\n\t\treturn map[string]interface{}{}\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unknown type %s\", t))\n\t}\n}\n","sourceCodeStart":1759,"sourceCodeEnd":1780,"githubUrl":"https://github.com/hashicorp/terraform/blob/c9def3e214014c1188faabfc4a5bde5095139765/internal/legacy/helper/schema/schema.go#L1759-L1780","documentation":"Panics in ValueType.Zero (schema.go:1777). The switch returns the Go zero value for every defined ValueType constant; the default panics. This means the ValueType passed in is an integer that does not correspond to any defined constant (TypeInvalid is handled and returns nil, so this is strictly an out-of-range value).","triggerScenarios":"A Schema.Type set to a numeric value outside the defined ValueType enum range — typically from unsafe int casting, reflection, fuzzing, or corrupt schema/state data — then Zero() is invoked.","commonSituations":"Interop/reflection code that casts arbitrary ints to ValueType, fuzz tests, or hand-assembled schema descriptors.","solutions":["Only ever assign defined schema.ValueType constants to Type.","Never cast an arbitrary int to ValueType; validate membership first.","If schema descriptors come from external data, validate the type id against the known constants before use."],"exampleFix":"// before\nvt := ValueType(someInt)  // someInt may be out of range\nv := vt.Zero()\n// after\nif vt < TypeInvalid || vt > typeObject { panic(\"bad type id\") }\nv := vt.Zero()","handlingStrategy":"type-guard","validationCode":"func valueTypeInRange(t schema.ValueType) bool {\n    return t >= schema.TypeInvalid && t <= schema.TypeSet\n}","typeGuard":"func knownValueType(t schema.ValueType) bool {\n    switch t {\n    case schema.TypeInvalid, schema.TypeBool, schema.TypeInt, schema.TypeFloat,\n        schema.TypeString, schema.TypeList, schema.TypeMap, schema.TypeSet:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Never cast arbitrary ints to ValueType.","Validate external type ids against known constants before use.","Avoid reflection-built schemas with raw type integers."],"tags":["terraform","schema","type","panic","internal"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}