apache/beam · error

unexpected edge: %v

Error message

unexpected edge: %v

What it means

makeLink's switch falls through to a default branch when the edge's Op is one the translator does not recognize. This means the graph contains an operation type the direct runner's translation table does not handle — either a very new edge kind from a newer SDK or an internal inconsistency. It is wrapped as 'unexpected edge: %v'.

Source

Thrown at sdks/go/pkg/beam/runners/direct/direct.go:343

		// on a single worker. Hoist the next node up in the cache.
		b.links[id] = out[0]
		return b.links[id], nil

	case graph.Flatten:
		u = &exec.Flatten{UID: b.idgen.New(), N: len(edge.Input), Out: out[0]}

		for i := 0; i < len(edge.Input); i++ {
			b.links[linkID{edge.ID(), i}] = u
		}

	case graph.WindowInto:
		u = &exec.WindowInto{UID: b.idgen.New(), Fn: edge.WindowFn, Out: out[0]}

	case graph.External:
		return nil, errors.Errorf("external transforms like %v are not supported in the Go direct runner, please execute your pipeline on a different runner", edge)

	default:
		return nil, errors.Errorf("unexpected edge: %v", edge)
	}

	b.links[id] = u
	b.units = append(b.units, u)
	return u, nil
}

View on GitHub (pinned to 12126d8942)

Solutions

  1. Check go.mod for mixed versions of github.com/apache/beam/sdks/v2 submodules and align them (go get -u ./... && go mod tidy).
  2. Upgrade the Beam Go SDK to the latest patch release — a newer op may simply be unhandled in your version.
  3. Identify the edge printed in the message; if it comes from custom graph code, ensure you only create edges with supported Ops.
  4. Report upstream if a stock SDK pipeline reproduces it (likely an SDK bug).

Example fix

// before
require github.com/apache/beam/sdks/v2 v2.45.0
require github.com/apache/beam/sdks/v2/go/pkg/beam v2.52.0 // mismatched
// after
require github.com/apache/beam/sdks/v2 v2.52.0
// then: go mod tidy && go build ./...
Defensive patterns

Strategy: try-catch

Try / catch

if _, err := beam.Run(ctx, runner, p); err != nil && strings.Contains(err.Error(), "unexpected edge") {
    log.Printf("check Beam SDK version alignment: %v", err)
}

Prevention

When it happens

Trigger: Compile/makeLinks walks an edge whose graph.Op is not one of the handled cases (CoGBK, ParDo, WindowInto, External, etc.) — typically after custom graph construction or an SDK version mismatch.

Common situations: Mixing Beam Go SDK module versions (go.mod misalignment) where the graph package emits ops the direct runner doesn't know; experimental/custom edges introduced by internal tooling; hand-built graphs in tests.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/48a7e74ba6239ec5. Report an issue: GitHub.