apache/beam · error

may only have a single BundleFinalization parameter and it…

Error message

may only have a single BundleFinalization parameter and it must precede the main input parameter

What it means

Sentinel error errBundleFinalizationPrecedence from the funcx parameter state machine: a typex.BundleFinalization parameter appeared after the main input parameter (as in the fn_test case where it follows the element and reflect.Type), or more than one was declared. Bundle finalization callbacks must be a single parameter preceding the main input.

Solutions

  1. Reorder so typex.BundleFinalization comes before the main input parameter
  2. Keep exactly one BundleFinalization parameter
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at sdks/go/pkg/beam/core/funcx/fn.go:536 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at sdks/go/pkg/beam/core/funcx/fn.go:536

	// Validate the return value ordering.
	retState := rsStart
	for i, r := range u.Ret {
		if retState, err = nextRetState(retState, r.Kind); err != nil {
			return errors.WithContextf(err, "validating return value %d for %s", i, u.Fn.Name())
		}
	}
	return nil
}

var (
	errContextParam                      = errors.New("may only have a single context.Context parameter and it must be the first parameter")
	errPaneParamPrecedence               = errors.New("may only have a single PaneInfo parameter and it must precede the WindowParam, EventTime and main input parameter")
	errWindowParamPrecedence             = errors.New("may only have a single Window parameter and it must precede the EventTime and main input parameter")
	errEventTimeParamPrecedence          = errors.New("may only have a single beam.EventTime parameter and it must precede the main input parameter")
	errWatermarkEstimatorParamPrecedence = errors.New("may only have a single sdf.WatermarkEstimator parameter and it must precede the main input parameter")
	errReflectTypePrecedence             = errors.New("may only have a single reflect.Type parameter and it must precede the main input parameter")
	errRTrackerPrecedence                = errors.New("may only have a single sdf.RTracker parameter and it must precede the main input parameter")
	errBundleFinalizationPrecedence      = errors.New("may only have a single BundleFinalization parameter and it must precede the main input parameter")
	errStateProviderPrecedence           = errors.New("may only have a single state.Provider parameter and it must precede the main input parameter")
	errTimerProviderPrecedence           = errors.New("may only have a single timer.Provider parameter and it must precede the main input parameter")
	errInputPrecedence                   = errors.New("inputs parameters must precede emit function parameters")
)

type paramState int

const (
	psStart paramState = iota
	psContext
	psPane
	psWindow
	psEventTime
	psWatermarkEstimator
	psType
	psInput
	psOutput
	psRTracker

View on GitHub (pinned to 12126d8942)