{"record":{"id":"b6efc2b7c7d81fcd","repo":"apache/beam","slug":"bad-nullable-v","errorCode":null,"errorMessage":"bad nullable: %+v","messagePattern":"bad nullable: %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/dataflow.go","lineNumber":287,"sourceCode":"\t\t\t\t\treturn nil, err\n\t\t\t\t}\n\n\t\t\t\tt := typex.New(typex.CoGBKType, append([]typex.FullType{key.T}, coder.Types(values)...)...)\n\t\t\t\treturn &coder.Coder{Kind: coder.CoGBK, T: t, Components: append([]*coder.Coder{key}, values...)}, nil\n\t\t\t}\n\t\t}\n\n\t\tvalue, err := DecodeCoderRef(elm)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tt := typex.New(typex.KVType, key.T, value.T)\n\t\treturn &coder.Coder{Kind: coder.KV, T: t, Components: []*coder.Coder{key, value}}, nil\n\n\tcase nullableType:\n\t\tif len(c.Components) != 1 {\n\t\t\treturn nil, errors.Errorf(\"bad nullable: %+v\", c)\n\t\t}\n\n\t\tinner, err := DecodeCoderRef(c.Components[0])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tt := typex.New(typex.NullableType, inner.T)\n\t\treturn &coder.Coder{Kind: coder.Nullable, T: t, Components: []*coder.Coder{inner}}, nil\n\n\tcase lengthPrefixType:\n\t\tif len(c.Components) != 1 {\n\t\t\treturn nil, errors.Errorf(\"bad length prefix: %+v\", c)\n\t\t}\n\n\t\tsubC := c.Components[0]\n\t\tswitch subC.Type {\n\t\tcase stringType: // Needs special handling if wrapped by dataflow.","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/dataflow.go#L269-L305","documentation":"DecodeCoderRef converts an encoded CoderRef back into a coder. A nullable-type ref must have exactly one component (the inner coder); any other count indicates a malformed or incompatible encoded form, so decoding aborts with the offending ref printed.","triggerScenarios":"Decoding a CoderRef with Type nullableType whose Components has length != 1 — during pipeline deserialization from a model pipeline (e.g. loading a saved pipeline or processing a Dataflow job description).","commonSituations":"Hand-edited or truncated pipeline JSON/proto artifacts; cross-SDK-version coder graphs; custom graph transforms that added or dropped components on nullable coders.","solutions":["Regenerate the pipeline artifact from the original pipeline; don't hand-edit encoded coder graphs.","Match the decoding SDK version to the encoding one.","Inspect the printed CoderRef to find which graph-rewriting step broke the component list.","If constructing CoderRefs programmatically, always wrap exactly one component for nullableType."],"exampleFix":"// before\nref := &graphx.CoderRef{Type: graphx.Nullable, Components: nil}\nc, err := graphx.DecodeCoderRef(ref)\n\n// after\nref := &graphx.CoderRef{Type: graphx.Nullable, Components: []*graphx.CoderRef{innerRef}}\nc, err := graphx.DecodeCoderRef(ref)","handlingStrategy":"try-catch","validationCode":"func validNullableRef(r *graphx.CoderRef) bool {\n\treturn r != nil && r.Type == graphx.Nullable && len(r.Components) == 1\n}","typeGuard":"func isNullableRef(r *graphx.CoderRef) bool { return r != nil && r.Type == graphx.Nullable && len(r.Components) == 1 }","tryCatchPattern":"c, err := graphx.DecodeCoderRef(ref)\nif err != nil {\n\tif strings.Contains(err.Error(), \"bad nullable\") {\n\t\treturn nil, fmt.Errorf(\"corrupt nullable coder ref %v: %w\", ref, err)\n\t}\n\treturn nil, err\n}","preventionTips":["Regenerate pipeline artifacts rather than reusing stale ones after SDK upgrades","Keep graph-rewriting passes component-count-preserving","Round-trip test: encode then decode every custom coder graph in tests"],"tags":["go","beam","coder-deserialization","nullable"],"backgroundTag":"unexpected-response-shape","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"}