apache/beam · error

errIllegalParametersInReIter

Error message

errIllegalParametersInReIter

What it means

unfoldReIter in sdks/go/pkg/beam/core/funcx/sideinput.go validates reiterator functions, which must have zero inputs and exactly one output. The output type is then recursively validated with unfoldIter; if that validation returns an error (e.g. the returned iterator function has illegal parameters), it is wrapped with errIllegalParametersInReIter. The library throws it so the failure clearly identifies the reiter signature as the offending function.

Source

Thrown at sdks/go/pkg/beam/core/funcx/sideinput.go:146

	return err != nil, err
}

// UnfoldReIter returns the parameter types, if a functional iterator generator.
func UnfoldReIter(t reflect.Type) ([]reflect.Type, bool) {
	types, ok, _ := unfoldReIter(t)
	return types, ok
}

func unfoldReIter(t reflect.Type) ([]reflect.Type, bool, error) {
	if t.Kind() != reflect.Func {
		return nil, false, nil
	}
	if t.NumIn() != 0 || t.NumOut() != 1 {
		return nil, false, nil
	}
	types, ok, err := unfoldIter(t.Out(0))
	if err != nil {
		err = errors.Wrap(err, errIllegalParametersInReIter)
	}
	return types, ok, err
}

// IsMultiMap returns true iff the supplied type is a keyed functional iterator
// generator.
//
// A keyed functional iterator generator is a function taking a single parameter
// (a key) and returns a corresponding single sweep functional iterator.
func IsMultiMap(t reflect.Type) bool {
	_, ok := UnfoldMultiMap(t)
	return ok
}

// IsMalformedMultiMap returns true iff the supplied type is an illegal keyed functional
// iterator generator and an error explaining why it is illegal. A keyed iterator generator
// is not legal if its output is not of type iterator. If the type does not have the
// structure of a keyed iterator generator or it is a legal iterator generator,

View on GitHub (pinned to 12126d8942)

Solutions

  1. Make the function's return value a valid iterator: `func() func(*T) bool` where T is a concrete PCollection element type.
  2. Fix the inner iterator signature first (pointer parameter, at most 2 params) since the wrapped error comes from unfoldIter on the output type.
  3. Verify with fx.IsReIter / fx.IsMalformedReIter in a test before wiring the pipeline.

Example fix

// before
reiter := func() *int { ... }
// after
reiter := func() func(*int) bool {
	s := ... // snapshot
	return func(i *int) bool { ... }
}
Defensive patterns

Strategy: validation

Validate before calling

func checkReIter(fn interface{}) error {
	t := reflect.TypeOf(fn)
	if t == nil || t.Kind() != reflect.Func {
		return fmt.Errorf("not a func: %T", fn)
	}
	if t.NumIn() != 0 || t.NumOut() != 1 {
		return fmt.Errorf("reiter must have 0 in, 1 out; got %d in, %d out", t.NumIn(), t.NumOut())
	}
	out := t.Out(0)
	if out.Kind() != reflect.Func {
		return fmt.Errorf("reiter output must be a func, got %v", out)
	}
	for i := 0; i < out.NumIn(); i++ {
		if out.In(i).Kind() != reflect.Ptr {
			return fmt.Errorf("inner iter param %d must be a pointer", i)
		}
	}
	return nil
}

Type guard

func isReIterShape(t reflect.Type) bool {
	return t != nil && t.Kind() == reflect.Func && t.NumIn() == 0 && t.NumOut() == 1 && t.Out(0).Kind() == reflect.Func
}

Try / catch

if _, ok, err := fx.UnfoldReIter(fn); err != nil {
	// err wraps errIllegalParametersInReIter
	return fmt.Errorf("bad reiter signature: %w", err)
}

Prevention

When it happens

Trigger: Providing a reiter function whose return value is not a valid iterator generator, e.g. `func() *int` (output does not unfold as an iter) or `func() func(x int) bool` where the inner iterator parameter is not a pointer type.

Common situations: Building repeated-iteration side inputs (GBE/reiter) where the inner closure signature was hand-written instead of matching `func() func(*T) bool`; renaming inner parameters/pointers during a refactor.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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