{"record":{"id":"48d6331e1ab10933","repo":"apache/beam","slug":"custom-coders-must-be-length-prefixed-v","errorCode":null,"errorMessage":"custom coders must be length prefixed: %+v","messagePattern":"custom coders must be length prefixed: %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/dataflow.go","lineNumber":357,"sourceCode":"\t\t}\n\n\t\tt := typex.New(reflect.SliceOf(inner.T.Type()), inner.T)\n\t\treturn &coder.Coder{Kind: coder.Iterable, T: t, Components: []*coder.Coder{inner}}, nil\n\n\tcase rowType:\n\t\tsubC := c.Components[0]\n\t\tschm := &pipepb.Schema{}\n\t\tif err := protox.DecodeBase64(subC.Type, schm); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tt, err := schema.ToType(schm)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &coder.Coder{Kind: coder.Row, T: typex.New(t)}, nil\n\n\tdefault:\n\t\treturn nil, errors.Errorf(\"custom coders must be length prefixed: %+v\", c)\n\t}\n}\n\nfunc decodeDataflowCustomCoder(payload string) (*coder.Coder, error) {\n\tvar ref v1pb.CustomCoder\n\tif err := protox.DecodeBase64(payload, &ref); err != nil {\n\t\treturn nil, errors.Wrapf(err, \"base64 decode for %v failed\", payload)\n\t}\n\tcustom, err := decodeCustomCoder(&ref)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tt := typex.New(custom.Type)\n\treturn &coder.Coder{Kind: coder.Custom, T: t, Custom: custom}, nil\n}\n\nfunc isCoGBKList(ref *CoderRef) ([]*CoderRef, bool) {\n\tif ref.Type != lengthPrefixType {","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/dataflow.go#L339-L375","documentation":"graphx.DecodeCoderRef converts a serialized Dataflow CoderRef into a beam coder. Only a limited set of coder kinds is supported; when the CoderRef kind does not match any known case (including the custom-coder path that requires a length-prefixed payload), it fails. Custom coders must carry a length-prefixed payload to be decoded.","triggerScenarios":"Decoding a CoderRef whose Kind is unrecognized, or a custom coder whose payload was not encoded with the required length-prefixing, via DecodeCoderRef / DecodeCoderRefs / DecodeCoder (typically while deserializing a saved model or pipeline for execution on a runner).","commonSituations":"Pipelines serialized by a different/newer Beam version introducing a coder kind this version doesn't know; hand-crafted or runner-rewritten coder refs; custom coders registered on one side of a job-submission boundary but not round-tripped correctly.","solutions":["Upgrade or align the Beam Go SDK version used to serialize and deserialize the pipeline so both sides support the same coder kinds.","Ensure custom coders are wrapped in a length-prefixed coder (CoderFromType / beam.EncodedCustomCoder) before serialization.","If the type can be represented natively, use a standard coder (RowCoder) instead of a custom coder."],"exampleFix":"// before: raw custom coder, not length prefixed\n// after\nbeam.CoderFromType(s, reflect.TypeOf(myType{})) // uses Row/length-prefixed representation\n// or ensure custom coder registration:\ncoder.RegisterCustomCoder(\"mycoder\", encode, decode)","handlingStrategy":"validation","validationCode":"// Before submitting: verify coder ref decodes\nif _, err := graphx.DecodeCoderRef(ref); err != nil {\n    return fmt.Errorf(\"unsupported coder ref kind %v: %w\", ref.Kind, err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    var unsupported bool\n    if strings.Contains(err.Error(), \"custom coders must be length prefixed\") { unsupported = true }\n    // fall back to RowCoder re-serialization\n}","preventionTips":["Keep SDK versions identical on submitter and runner","Always wrap custom coders in length-prefixed form","Prefer RowCoder for serializable types"],"tags":["go","beam","coder","serialization"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}