{"record":{"id":"3cfefeb1ea2e3a17","repo":"apache/beam","slug":"invalid-class-value-v","errorCode":null,"errorMessage":"invalid Class value: %v","messagePattern":"invalid Class value: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"sdks/go/pkg/beam/core/typex/class.go","lineNumber":64,"sourceCode":"\t// Composite type: KV, CoGBk, WindowedValue. Beam-generic types\n\t// that cannot be represented as a single reflect.Type.\n\tComposite\n)\n\nfunc (c Class) String() string {\n\tswitch c {\n\tcase Invalid:\n\t\treturn \"Invalid\"\n\tcase Concrete:\n\t\treturn \"Concrete\"\n\tcase Universal:\n\t\treturn \"Universal\"\n\tcase Container:\n\t\treturn \"Container\"\n\tcase Composite:\n\t\treturn \"Composite\"\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"invalid Class value: %v\", int(c)))\n\t}\n}\n\n// TODO(herohde) 5/16/2017: maybe we should add more classes, so that every\n// reasonable type (such as error) is not Invalid, even though it is not\n// valid in FullType. \"Special\", say? Right now, a valid DoFn signature may\n// have \"Invalid\" parameter types, which might be confusing. Or maybe rename\n// as DataClass to make the narrower scope clearer?\n\n// ClassOf returns the class of a given type. The class is Invalid, if the\n// type is not suitable as data.\nfunc ClassOf(t reflect.Type) Class {\n\tswitch {\n\tcase IsUniversal(t):\n\t\treturn Universal\n\tcase IsComposite(t):\n\t\treturn Composite\n\tcase IsContainer(t): // overrules IsConcrete","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/typex/class.go#L46-L82","documentation":"Class.String() panics when the Class value does not match any known class (Booleans, Integer, Decimal, Float, Byte, String, Universal, Container, Composite). Class is an internal enum of typex type classifications, so receiving this panic means a Class value outside the defined enum range was constructed, e.g. via an unsafe conversion from an integer.","triggerScenarios":"Calling String() on a Class produced by an out-of-range int conversion (e.g. typex.Class(99)); normally only reachable through misuse of internal typex APIs, not through public Beam pipeline construction.","commonSituations":"Custom code that builds FullType trees by hand; test harnesses or code generators constructing Class values numerically; SDK-internal bugs after adding a new class without updating String().","solutions":["Inspect how the invalid Class value was created; only use the exported Class constants (typex.Booleans, typex.Container, etc.).","Never cast raw integers to typex.Class; derive classes via typex.New(t) from reflect.Type values.","If hit inside the SDK after an upgrade, report/patch: a new Class variant was likely added without updating String()."],"exampleFix":"// before\nc := typex.Class(99)\nfmt.Println(c.String()) // panics\n// after\nvar c typex.Class = typex.Container\nfmt.Println(c.String())","handlingStrategy":"type-guard","validationCode":"if c < typex.Booleans || c > typex.Composite { return fmt.Errorf(\"invalid Class: %d\", int(c)) }","typeGuard":"func isValidClass(c typex.Class) bool {\n\tswitch c {\n\tcase typex.Booleans, typex.Integer, typex.Decimal, typex.Float, typex.Byte, typex.String, typex.Universal, typex.Container, typex.Composite:\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"defer func() {\n\tif r := recover(); r != nil {\n\t\tlog.Printf(\"typex Class panic: %v\", r)\n\t}\n}()","preventionTips":["Only use exported typex.Class constants; never cast integers to Class.","Derive types via typex.New from reflect.Type rather than assembling classes manually."],"tags":["go","beam","typex","invalid-enum-value","panic"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}