apache/beam · error

bad input kind

Error message

bad input kind

What it means

DecodeMultiEdge reconstructs a MultiEdge from its serialized form, calling decodeInputKind for each inbound edge. When the inbound edge's serialized Kind string cannot be resolved to a known input kind, the error is wrapped as "bad input kind" and annotated with the edge being decoded. It indicates the graph model file is corrupt, hand-edited, or produced by an incompatible Beam version.

Source

Thrown at sdks/go/pkg/beam/core/runtime/graphx/serialize.go:115

	var outbound []*graph.Outbound

	opcode := graph.Opcode(edge.Opcode)

	if edge.Fn != nil {
		var err error
		u, err = decodeFn(edge.Fn)
		if err != nil {
			wrapped := errors.Wrap(err, "bad function")
			return "", nil, nil, nil, nil, errors.WithContextf(wrapped, "decoding userfn %v", edge)
		}
	}
	if edge.WindowFn != nil {
		wfn = decodeWindowFn(edge.WindowFn)
	}
	for _, in := range edge.Inbound {
		kind, err := decodeInputKind(in.Kind)
		if err != nil {
			wrapped := errors.Wrap(err, "bad input kind")
			return "", nil, nil, nil, nil, errors.WithContextf(wrapped, "decoding userfn %v", edge)
		}
		t, err := decodeFullType(in.Type)
		if err != nil {
			wrapped := errors.Wrap(err, "bad input type")
			return "", nil, nil, nil, nil, errors.WithContextf(wrapped, "decoding userfn %v", edge)
		}
		inbound = append(inbound, &graph.Inbound{Kind: kind, Type: t})
	}
	for _, out := range edge.Outbound {
		t, err := decodeFullType(out.Type)
		if err != nil {
			wrapped := errors.Wrap(err, "bad output type")
			return "", nil, nil, nil, nil, errors.WithContextf(wrapped, "decoding userfn %v", edge)
		}
		outbound = append(outbound, &graph.Outbound{Type: t})
	}

View on GitHub (pinned to 12126d8942)

Solutions

  1. Use the same (or compatible) Beam version to encode and decode the graph model
  2. Regenerate the model file from the original pipeline rather than editing it by hand
  3. Check model file integrity (not truncated/corrupted)
  4. Inspect edge.Inbound[].Kind values against graphx's valid kind strings to find the offender

Example fix

// before: decoding a model produced by a newer Beam
model, _ := ioutil.ReadFile("model.json")
graphx.DecodeMultiEdge(model)
// after: align SDK versions with the producer of the model
// (no code change — pin sdks/go version to match the writer, then re-run)
Defensive patterns

Strategy: try-catch

Validate before calling

for _, in := range edge.Inbound {
	if _, err := graphx.DecodeInputKind(in.Kind); err != nil {
		return fmt.Errorf("unrecognized inbound kind %q", in.Kind)
	}
}

Try / catch

edge, err := graphx.DecodeMultiEdge(data)
if err != nil {
	if strings.Contains(err.Error(), "bad input kind") {
		return fmt.Errorf("model file incompatible or corrupted: %w", err)
	}
	return err
}

Prevention

When it happens

Trigger: Calling DecodeMultiEdge (directly or via makeLink/DecodeGraph) on a ModelEdge whose Inbound[i].Kind contains an unrecognized kind string — e.g. a model file serialized with a newer Beam version that added a new input kind, or a manually modified/corrupted model JSON/protobuf.

Common situations: Deserializing a pipeline model file generated by a different Beam SDK version; hand-editing model files; truncation or corruption of the serialized graph during storage/transfer.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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