{"record":{"id":"17d961e42ca183fb","repo":"apache/beam","slug":"errillegalparametersinreiter","errorCode":null,"errorMessage":"errIllegalParametersInReIter","messagePattern":"errIllegalParametersInReIter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/funcx/sideinput.go","lineNumber":146,"sourceCode":"\treturn err != nil, err\n}\n\n// UnfoldReIter returns the parameter types, if a functional iterator generator.\nfunc UnfoldReIter(t reflect.Type) ([]reflect.Type, bool) {\n\ttypes, ok, _ := unfoldReIter(t)\n\treturn types, ok\n}\n\nfunc unfoldReIter(t reflect.Type) ([]reflect.Type, bool, error) {\n\tif t.Kind() != reflect.Func {\n\t\treturn nil, false, nil\n\t}\n\tif t.NumIn() != 0 || t.NumOut() != 1 {\n\t\treturn nil, false, nil\n\t}\n\ttypes, ok, err := unfoldIter(t.Out(0))\n\tif err != nil {\n\t\terr = errors.Wrap(err, errIllegalParametersInReIter)\n\t}\n\treturn types, ok, err\n}\n\n// IsMultiMap returns true iff the supplied type is a keyed functional iterator\n// generator.\n//\n// A keyed functional iterator generator is a function taking a single parameter\n// (a key) and returns a corresponding single sweep functional iterator.\nfunc IsMultiMap(t reflect.Type) bool {\n\t_, ok := UnfoldMultiMap(t)\n\treturn ok\n}\n\n// IsMalformedMultiMap returns true iff the supplied type is an illegal keyed functional\n// iterator generator and an error explaining why it is illegal. A keyed iterator generator\n// is not legal if its output is not of type iterator. If the type does not have the\n// structure of a keyed iterator generator or it is a legal iterator generator,","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/funcx/sideinput.go#L128-L164","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Make the function's return value a valid iterator: `func() func(*T) bool` where T is a concrete PCollection element type.","Fix the inner iterator signature first (pointer parameter, at most 2 params) since the wrapped error comes from unfoldIter on the output type.","Verify with fx.IsReIter / fx.IsMalformedReIter in a test before wiring the pipeline."],"exampleFix":"// before\nreiter := func() *int { ... }\n// after\nreiter := func() func(*int) bool {\n\ts := ... // snapshot\n\treturn func(i *int) bool { ... }\n}","handlingStrategy":"validation","validationCode":"func checkReIter(fn interface{}) error {\n\tt := reflect.TypeOf(fn)\n\tif t == nil || t.Kind() != reflect.Func {\n\t\treturn fmt.Errorf(\"not a func: %T\", fn)\n\t}\n\tif t.NumIn() != 0 || t.NumOut() != 1 {\n\t\treturn fmt.Errorf(\"reiter must have 0 in, 1 out; got %d in, %d out\", t.NumIn(), t.NumOut())\n\t}\n\tout := t.Out(0)\n\tif out.Kind() != reflect.Func {\n\t\treturn fmt.Errorf(\"reiter output must be a func, got %v\", out)\n\t}\n\tfor i := 0; i < out.NumIn(); i++ {\n\t\tif out.In(i).Kind() != reflect.Ptr {\n\t\t\treturn fmt.Errorf(\"inner iter param %d must be a pointer\", i)\n\t\t}\n\t}\n\treturn nil\n}","typeGuard":"func isReIterShape(t reflect.Type) bool {\n\treturn t != nil && t.Kind() == reflect.Func && t.NumIn() == 0 && t.NumOut() == 1 && t.Out(0).Kind() == reflect.Func\n}","tryCatchPattern":"if _, ok, err := fx.UnfoldReIter(fn); err != nil {\n\t// err wraps errIllegalParametersInReIter\n\treturn fmt.Errorf(\"bad reiter signature: %w\", err)\n}","preventionTips":["Template reiter functions as `func() func(*T) bool` and only substitute T.","Keep a passing fixture test using fx.IsReIter for each reiter you ship.","Remember the inner iterator must itself satisfy the iter rules (pointer params)."],"tags":["go","beam","reiter","side-input","function-signature"],"backgroundTag":"invalid-argument-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}