{"record":{"id":"8d1e22c32f261182","repo":"apache/beam","slug":"failed-to-marshal-the-coder-v","errorCode":null,"errorMessage":"failed to marshal the coder %v.","messagePattern":"failed to marshal the coder (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/coder.go","lineNumber":592,"sourceCode":"\tcase coder.Iterable:\n\t\tcomp, err := b.AddMulti(c.Components)\n\t\tif err != nil {\n\t\t\treturn \"\", errors.Wrapf(err, \"failed to marshal iterable coder %v\", c)\n\t\t}\n\t\treturn b.internBuiltInCoder(urnIterableCoder, comp...), nil\n\n\tdefault:\n\t\terr := errors.Errorf(\"unexpected coder kind: %v\", c.Kind)\n\t\treturn \"\", errors.WithContextf(err, \"failed to marshal coder %v\", c)\n\t}\n}\n\n// AddMulti adds the given coders to the set and returns their ids. Idempotent.\nfunc (b *CoderMarshaller) AddMulti(list []*coder.Coder) ([]string, error) {\n\tvar ids []string\n\tfor _, c := range list {\n\t\tif id, err := b.Add(c); err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to marshal the coder %v.\", c)\n\t\t} else {\n\t\t\tids = append(ids, id)\n\t\t}\n\t}\n\treturn ids, nil\n}\n\n// AddWindowCoder adds a window coder.\nfunc (b *CoderMarshaller) AddWindowCoder(w *coder.WindowCoder) (string, error) {\n\tswitch w.Kind {\n\tcase coder.GlobalWindow:\n\t\treturn b.internBuiltInCoder(urnGlobalWindow), nil\n\tcase coder.IntervalWindow:\n\t\treturn b.internBuiltInCoder(urnIntervalWindow), nil\n\tdefault:\n\t\terr := errors.Errorf(\"window coder with unexpected type %v\", w.Kind)\n\t\treturn \"\", errors.WithContextf(err, \"failed to unmarshal window coder %v\", w)\n\t}","sourceCodeStart":574,"sourceCodeEnd":610,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/coder.go#L574-L610","documentation":"Produced by CoderMarshaller.AddMulti, which iterates a list of coders and calls Add for each. If any individual coder fails to marshal, the error is wrapped as 'failed to marshal the coder %v.' identifying the specific failing coder. It exists so batch marshalling (e.g. for composite coders) names the offending element.","triggerScenarios":"Calling AddMulti with a slice containing any coder that Add rejects (unsupported kind, failing window coder, failing nested components); also reached whenever Add is called and any underlying marshalling step fails.","commonSituations":"Composite (KV/Iterable) coders with one bad component; MarshalCoders at pipeline serialization time when some PCollection has an unsupported coder; cross-language expansion producing coders unknown to Go.","solutions":["From the message, identify the exact failing coder %v and inspect its Kind and components.","Fix or replace that coder with a supported kind.","Marshalling the list element-by-element yourself to pinpoint failures early.","Ensure every PCollection's type has a default coder Beam can build (registered custom encoders if needed).","Align Beam versions across SDKs used in the pipeline."],"exampleFix":"// before\nids, err := b.AddMulti([]*coder.Coder{good, badUnknownCoder})\n// after\nids, err := b.AddMulti([]*coder.Coder{good, coder.NewBytes()}) // replace unsupported coder","handlingStrategy":"validation","validationCode":"for i, c := range list {\n    if c == nil {\n        return fmt.Errorf(\"coder at index %d is nil\", i)\n    }\n}","typeGuard":"func allMarshalable(list []*coder.Coder) bool {\n    for _, c := range list {\n        if c == nil || c.Kind == 0 {\n            return false\n        }\n    }\n    return true\n}","tryCatchPattern":"ids, err := b.AddMulti(list)\nif err != nil {\n    return nil, fmt.Errorf(\"AddMulti: %w\", err) // message names the failing coder\n}","preventionTips":["Validate each PCollection's coder before pipeline serialization.","Log the failing coder from the error message to fix it at the source.","Use only Beam coder constructors."],"tags":["go","apache-beam","serialization"],"backgroundTag":"json-marshal-failed","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"}