apache/beam · error

bad input type

Error message

bad input type

What it means

EncodeMultiEdge wraps encodeInputKind failures as 'bad input type'. encodeInputKind converts the link's graph.InputKind (Main, Iter, CoGBK, Slice, Multi, Union) to its protobuf enum; an input kind with no protobuf mapping cannot be encoded, so graph serialization aborts with context 'encoding userfn'.

Solutions

  1. Read the inner error from encodeInputKind to see the offending kind value
  2. Upgrade the Beam Go SDK so encodeInputKind covers the input kind in use
  3. Rebuild the pipeline graph with matching beam package versions (no stale vendored copies)
  4. If constructing edges manually, use only documented graph.InputKind values

Example fix

// before
custom edge with in.Kind = graph.InputKind(42) // unmapped
// after
in.Kind = graph.Main // or upgrade graphx so the kind is encoded
Defensive patterns

Strategy: validation

Validate before calling

for _, in := range edge.Input {
  if _, err := encodeInputKind(in.Kind); err != nil {
    return fmt.Errorf("input kind %v unsupported by this graphx version", in.Kind)
  }
}

Type guard

func knownInputKind(k graph.InputKind) bool {
  switch k {
  case graph.Main, graph.Slice, graph.Iter, graph.CoGBK, graph.Multi, graph.Union:
    return true
  }
  return false
}

Try / catch

kind, err := encodeInputKind(in.Kind)
if err != nil {
  return fmt.Errorf("input kind %v requires a newer Beam SDK: %w", in.Kind, err)
}

Prevention

When it happens

Trigger: EncodeMultiEdge iterating edge.Input where one input's Kind has no corresponding encodeInputKind case — typically a newly added/unknown InputKind or a corrupted graph built with mismatched beam package versions.

Common situations: Using a beam version where a new input kind was introduced but the runtime graphx encoder predates it; building MultiEdge structures manually in custom code paths.

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/dcbdeb47d4b3386d. Report an issue: GitHub.

Appendix: source

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

		}
		ret.Fn = ref
	}
	if edge.CombineFn != nil {
		ref, err := encodeFn((*graph.Fn)(edge.CombineFn))
		if err != nil {
			wrapped := errors.Wrap(err, "bad combinefn")
			return nil, errors.WithContextf(wrapped, "encoding userfn %v", edge)
		}
		ret.Fn = ref
	}
	if edge.WindowFn != nil {
		ret.WindowFn = encodeWindowFn(edge.WindowFn)
	}

	for _, in := range edge.Input {
		kind, err := encodeInputKind(in.Kind)
		if err != nil {
			wrapped := errors.Wrap(err, "bad input type")
			return nil, errors.WithContextf(wrapped, "encoding userfn %v", edge)
		}
		t, err := encodeFullType(in.Type)
		if err != nil {
			wrapped := errors.Wrap(err, "bad input type")
			return nil, errors.WithContextf(wrapped, "encoding userfn %v", edge)
		}
		ret.Inbound = append(ret.Inbound, &v1pb.MultiEdge_Inbound{Kind: kind, Type: t})
	}
	for _, out := range edge.Output {
		t, err := encodeFullType(out.Type)
		if err != nil {
			wrapped := errors.Wrap(err, "bad output type")
			return nil, errors.WithContextf(wrapped, "encoding userfn %v", edge)
		}
		ret.Outbound = append(ret.Outbound, &v1pb.MultiEdge_Outbound{Type: t})
	}
	return ret, nil

View on GitHub (pinned to 12126d8942)