apache/beam · error
empty graph
Error message
empty graph
What it means
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.
Source
Thrown at sdks/go/pkg/beam/core/runtime/graphx/translate.go:185
PipelineResourceHints resource.Hints
// ContextReg is an override for the context extractor registry for testing.
ContextReg *contextreg.Registry
}
// GetContextReg returns the default context registry if the option is
// unset, and the field version otherwise.
func (opts *Options) GetContextReg() *contextreg.Registry {
if opts.ContextReg == nil {
return contextreg.Default()
}
return opts.ContextReg
}
// Marshal converts a graph to a model pipeline.
func Marshal(edges []*graph.MultiEdge, opt *Options) (*pipepb.Pipeline, error) {
if len(edges) == 0 {
return nil, errors.New("empty graph")
}
tree := NewScopeTree(edges)
m := newMarshaller(opt)
for _, edge := range tree.Edges {
_, err := m.addMultiEdge(edge)
if err != nil {
return nil, err
}
}
for _, t := range tree.Children {
_, err := m.addScopeTree(t)
if err != nil {
return nil, err
}
}
View on GitHub (pinned to 12126d8942)
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.
Example fix
// before
pipeline, err := graphx.Marshal(edges, opts)
// after
if len(edges) == 0 { return nil, fmt.Errorf("pipeline has no transforms") }
pipeline, err := graphx.Marshal(edges, opts) Defensive patterns
Strategy: validation
Validate before calling
if len(edges) == 0 { return errors.New("cannot marshal: pipeline graph has no transforms") } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- empty type
- encoding partition function
- The pipeline has not been run.
- The pipeline contains abandoned PTransform(s).
- PCollections come from different Pipelines
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/fff3dcb07dee0c78.
Report an issue: GitHub.