{"record":{"id":"fff3dcb07dee0c78","repo":"apache/beam","slug":"empty-graph","errorCode":null,"errorMessage":"empty graph","messagePattern":"empty graph","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/translate.go","lineNumber":185,"sourceCode":"\tPipelineResourceHints resource.Hints\n\n\t// ContextReg is an override for the context extractor registry for testing.\n\tContextReg *contextreg.Registry\n}\n\n// GetContextReg returns the default context registry if the option is\n// unset, and the field version otherwise.\nfunc (opts *Options) GetContextReg() *contextreg.Registry {\n\tif opts.ContextReg == nil {\n\t\treturn contextreg.Default()\n\t}\n\treturn opts.ContextReg\n}\n\n// Marshal converts a graph to a model pipeline.\nfunc Marshal(edges []*graph.MultiEdge, opt *Options) (*pipepb.Pipeline, error) {\n\tif len(edges) == 0 {\n\t\treturn nil, errors.New(\"empty graph\")\n\t}\n\n\ttree := NewScopeTree(edges)\n\n\tm := newMarshaller(opt)\n\tfor _, edge := range tree.Edges {\n\t\t_, err := m.addMultiEdge(edge)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n\tfor _, t := range tree.Children {\n\t\t_, err := m.addScopeTree(t)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t}\n","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/translate.go#L167-L203","documentation":"graphx.Marshal converts a list of graph MultiEdges into a pipepb.Pipeline model pipeline. An empty edge list means there is no graph to convert, so Marshal rejects it up front with this error instead of emitting a degenerate pipeline.","triggerScenarios":"Calling Marshal (directly or via Expand/Execute paths) with a nil or zero-length edges slice — e.g. a constructed pipeline that produced no transforms, or a test passing an empty graph.","commonSituations":"Building a pipeline programmatically without adding any transforms before externalizing/running it; a filter/branch step eliminating all edges; unit tests exercising Marshal with empty input.","solutions":["Add at least one PTransform/edge to the pipeline before marshaling.","Check the code path that builds the edges slice for logic that can drop all edges.","Guard call sites: verify len(edges) > 0 before calling Marshal."],"exampleFix":"// before\npipeline, err := graphx.Marshal(edges, opts)\n// after\nif len(edges) == 0 { return nil, fmt.Errorf(\"pipeline has no transforms\") }\npipeline, err := graphx.Marshal(edges, opts)","handlingStrategy":"validation","validationCode":"if len(edges) == 0 { return errors.New(\"cannot marshal: pipeline graph has no transforms\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the pipeline has at least one transform before externalizing/running","Check branch/filter logic that could remove all edges","Assert non-empty graph in tests that exercise Marshal"],"tags":["go","apache-beam","graphx","marshal","pipeline"],"backgroundTag":"empty-required-field","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"}