{"record":{"id":"61f49aede974df84","repo":"apache/beam","slug":"type-v-of-kind-v-not-permitted-in-concrete-types-all-types-61f49a","errorCode":null,"errorMessage":"Type \"%v\" of kind \"%v\" not permitted in concrete types. All types must be serializable.","messagePattern":"Type \"(.+?)\" of kind \"(.+?)\" not permitted in concrete types\\. All types must be serializable\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/typex/class.go","lineNumber":135,"sourceCode":"\t// Handle special types.\n\tif t == nil ||\n\t\tt == EventTimeType ||\n\t\tt.Implements(WindowType) ||\n\t\tt == PaneInfoType ||\n\t\tt == TimersType ||\n\t\tt == BundleFinalizationType ||\n\t\tt == reflectx.Error ||\n\t\tt == reflectx.Context ||\n\t\tIsUniversal(t) {\n\t\treturn errors.Errorf(\"Special type \\\"%v\\\" not permitted in concrete types\", t)\n\t}\n\n\tswitch t.Kind() {\n\tcase reflect.Invalid, reflect.UnsafePointer, reflect.Uintptr:\n\t\treturn errors.Errorf(\"Type \\\"%v\\\" of kind \\\"%v\\\" not permitted in concrete types. All types must be manageable.\", t, t.Kind()) // no unmanageable types\n\n\tcase reflect.Chan, reflect.Func:\n\t\treturn errors.Errorf(\"Type \\\"%v\\\" of kind \\\"%v\\\" not permitted in concrete types. All types must be serializable.\", t, t.Kind()) // no unserializable types\n\n\tcase reflect.Map:\n\t\terr := isConcrete(t.Elem(), visited)\n\t\tif err == nil {\n\t\t\terr = isConcrete(t.Key(), visited)\n\t\t}\n\t\tif err != nil {\n\t\t\terr = errors.Wrapf(err, \"Nested type in map \\\"%v\\\" not permitted in concrete types.\", t)\n\t\t}\n\t\treturn err\n\n\tcase reflect.Array, reflect.Slice, reflect.Ptr:\n\t\terr := isConcrete(t.Elem(), visited)\n\t\tif err != nil {\n\t\t\terr = errors.Wrapf(err, \"Nested type in %v \\\"%v\\\" not permitted in concrete types.\", t.Kind(), t)\n\t\t}\n\t\treturn err\n","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/typex/class.go#L117-L153","documentation":"isConcrete rejects element types whose Go kind is unserializable: Chan or Func. Beam must serialize elements between bundles and across workers, and channels/functions cannot be encoded, so any concrete type graph containing them (exported, at any nesting depth) is rejected. Reached via IsConcrete/CheckConcrete when declaring DoFn or PCollection element types.","triggerScenarios":"A DoFn input/output type (or a nested exported field) that is a channel (chan int) or a function value (func() error); slices/maps of channels or funcs; embedding a callback field in a data struct.","commonSituations":"Passing callbacks through PCollections to 'configure downstream behavior'; structs with notifier channels for tests reused as element types; wrapping io.Reader/func() error in event records.","solutions":["Remove chan/func fields from element types; unexport them if they are only runtime-local state.","Replace callback fields with data (e.g. an enum/flag the worker interprets) and reconstruct behavior in the DoFn.","For notification-style patterns, emit identifiers and resolve behavior on the consumer side.","Call typex.CheckConcrete(reflect.TypeOf(myElem)) early in tests to catch offending nested fields."],"exampleFix":"// before\ntype Event struct {\n    OnDone func()\n}\n\n// after\ntype Event struct {\n    DoneFlag bool\n}","handlingStrategy":"type-guard","validationCode":"func serializable(t reflect.Type) error {\n    switch t.Kind() {\n    case reflect.Chan, reflect.Func:\n        return fmt.Errorf(\"unserializable kind %v in %v\", t.Kind(), t)\n    }\n    return nil\n}","typeGuard":"func hasChanOrFunc(t reflect.Type) bool {\n    switch t.Kind() {\n    case reflect.Chan, reflect.Func:\n        return true\n    }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Never include chan or func fields in element types — export or not, they surface via exported wrappers.","Replace callbacks with data-driven flags resolved inside DoFns.","Validate element types with typex.CheckConcrete before pipeline construction."],"tags":["go","apache-beam","type-system","serialization"],"backgroundTag":"unsupported-dtype","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}