{"record":{"id":"cb41af21bde14741","repo":"apache/beam","slug":"bad-coder-kind-v","errorCode":null,"errorMessage":"bad coder kind: %v","messagePattern":"bad coder kind: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/dataflow.go","lineNumber":215,"sourceCode":"\t\t\tComponents: []*CoderRef{{Type: stringType, PipelineProtoCoderID: c.ID}},\n\t\t}, nil\n\n\tcase coder.Row:\n\t\tschm, err := schema.FromType(c.T.Type())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tdata, err := protox.EncodeBase64(schm)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &CoderRef{\n\t\t\tType:       rowType,\n\t\t\tComponents: []*CoderRef{{Type: data}},\n\t\t}, nil\n\n\tdefault:\n\t\treturn nil, errors.Errorf(\"bad coder kind: %v\", c.Kind)\n\t}\n}\n\n// DecodeCoderRefs extracts usable coders from the encoded runner form.\nfunc DecodeCoderRefs(list []*CoderRef) ([]*coder.Coder, error) {\n\tvar ret []*coder.Coder\n\tfor _, ref := range list {\n\t\tc, err := DecodeCoderRef(ref)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tret = append(ret, c)\n\t}\n\treturn ret, nil\n}\n\n// DecodeCoderRef extracts a usable coder from the encoded runner form.\nfunc DecodeCoderRef(c *CoderRef) (*coder.Coder, error) {","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/dataflow.go#L197-L233","documentation":"EncodeCoderRef switches on the coder's Kind to map it to a runner-side CoderRef type. The default branch is reached when the Kind value is not any known/encodable kind (e.g. K=0 zero-value coders or custom kinds the Dataflow encoder doesn't support), so it fails with 'bad coder kind'.","triggerScenarios":"Encoding a coder.Coder whose Kind is unrecognized by graphx: a zero-value Coder{}, a custom coder kind defined outside the core package, or a kind added in a newer Beam version than the one doing the encoding.","commonSituations":"Passing an uninitialized Coder struct; custom DoFns emitting values whose inferred coder kind isn't supported for the Dataflow runner; SDK version skew where a coder kind exists at decode time but not at encode time; row-encoder-requiring custom types lacking a registered coder.","solutions":["Print/log c.Kind to identify the unsupported kind and ensure the coder is initialized through a supported constructor.","Register a supported coder (custom coder via beam.Encoder/Decoder registration) for the offending type instead of relying on inference.","Check that no zero-value coder.Coder is being passed (uninitialized struct).","Upgrade/downgrade the Beam Go SDK so encode and decode support the same coder kinds."],"exampleFix":"// before\nvar c coder.Coder // Kind: \"\" (zero value)\nref, err := graphx.EncodeCoderRef(&c)\n\n// after\nc := coder.NewString() // supported kind\nref, err := graphx.EncodeCoderRef(c)","handlingStrategy":"try-catch","validationCode":"func kindEncodable(k coder.Kind) bool {\n\tswitch k {\n\tcase coder.Bytes, coder.Bool, coder.VarInt, coder.Double, coder.String,\n\t\tcoder.KV, coder.CoGBK, coder.Iterable, coder.WindowedValue, coder.Nullable, coder.Row:\n\t\treturn true\n\t}\n\treturn false\n}","typeGuard":"func isKnownKind(c *coder.Coder) bool { return c != nil && c.Kind != 0 && kindEncodable(c.Kind) }","tryCatchPattern":"ref, err := graphx.EncodeCoderRef(c)\nif err != nil {\n\tvar unsupported = errors.New(\"coder kind not encodable for this runner\")\n\tif strings.Contains(err.Error(), \"bad coder kind\") {\n\t\treturn fmt.Errorf(\"%w (kind=%v): register a supported coder for this type\", unsupported, c.Kind)\n\t}\n\treturn err\n}","preventionTips":["Never pass zero-value coder.Coder structs","Register custom encoders via beam.CustomCoder for unsupported types","Keep the SDK version uniform across all pipeline tooling"],"tags":["go","beam","coder","unsupported-kind"],"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-20T03:17:13.778Z"}