apache/beam · error

Unrecognized state type %v

Error message

Unrecognized state type %v

What it means

makeLink enumerates a ParDo's user-state specs (ReadModifyWrite, Bag, Combining, Map, Set, OrderedList) when reconstructing execution units. If a state spec is none of these, the decoder cannot interpret the state type and fails with 'Unrecognized state type'.

Source

Thrown at sdks/go/pkg/beam/core/runtime/exec/translate.go:569

								}
								_, fn, _, _, _, err := graphx.DecodeMultiEdge(cmbTp.GetEdge())
								if err != nil {
									return nil, err
								}
								cfn, err := graph.AsCombineFn(fn)
								if err != nil {
									return nil, err
								}
								stateIDToCombineFn[key] = cfn
							} else if ms := spec.GetMapSpec(); ms != nil {
								cID = ms.ValueCoderId
								kcID = ms.KeyCoderId
							} else if ss := spec.GetSetSpec(); ss != nil {
								kcID = ss.ElementCoderId
							} else if ols := spec.GetOrderedListSpec(); ols != nil {
								cID = ols.ElementCoderId
							} else {
								return nil, errors.Errorf("Unrecognized state type %v", spec)
							}
							if cID != "" {
								c, err := b.coders.Coder(cID)
								if err != nil {
									return nil, err
								}
								stateIDToCoder[key] = c
							} else {
								// If no value coder is provided, we are in a keyed state with no values (aka a set).
								// We represent a set as an element mapping to a bool representing if it is present or not.
								stateIDToCoder[key] = &coder.Coder{Kind: coder.Bool}
							}
							if kcID != "" {
								kc, err := b.coders.Coder(kcID)
								if err != nil {
									return nil, err
								}
								stateIDToKeyCoder[key] = kc

View on GitHub (pinned to 12126d8942)

Solutions

  1. Upgrade the Go Beam SDK harness to match (or exceed) the version that built the pipeline
  2. Check the spec oneof: ensure exactly one of ReadModifyWriteSpec/BagSpec/CombiningSpec/MapSpec/SetSpec/OrderedListSpec is set
  3. Re-encode the pipeline with the Go SDK instead of hand-building the StateSpec protobuf

Example fix

null
Defensive patterns

Strategy: validation

Validate before calling

func stateSpecKnown(spec *pipepb.StateSpec) error {
	switch {
	case spec.GetReadModifyWriteSpec() != nil, spec.GetBagSpec() != nil,
		spec.GetCombiningSpec() != nil, spec.GetMapSpec() != nil,
		spec.GetSetSpec() != nil, spec.GetOrderedListSpec() != nil:
		return nil
	}
	return fmt.Errorf("unsupported state spec: %v", spec)
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: A UserState spec in the pipeline protobuf with all spec oneof fields empty or set to a newer/unknown state type (e.g. a state kind this SDK version doesn't know), typically when a newer pipeline is run against an older SDK harness.

Common situations: Version skew between pipeline builder and Go FnAPI harness; a custom runner emitting unpopulated StateSpec protos; hand-crafted pipeline graphs.

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