apache/beam · error
CreateTracker has unexpected number of parameters: %v
Error message
CreateTracker has unexpected number of parameters: %v
What it means
The CreateTracker function of an SDF must take 1 or 2 parameters (the restriction, optionally plus the element) and return an sdf.RTracker. initCallFn rejects other arities with this error during invoker initialization, as no supported call path can invoke the function.
Source
Thrown at sdks/go/pkg/beam/core/runtime/exec/sdf_invokers_arity.go:254
r0 := fnT.Call2x1(n.args[0], n.args[1])
return r0.(sdf.RTracker), nil
}
case reflectx.Func1x2:
n.call = func() (rt sdf.RTracker, err error) {
r0, r1 := fnT.Call1x2(n.args[0])
return r0.(sdf.RTracker), asError(r1)
}
case reflectx.Func2x2:
n.call = func() (rt sdf.RTracker, err error) {
r0, r1 := fnT.Call2x2(n.args[0], n.args[1])
return r0.(sdf.RTracker), asError(r1)
}
default:
if len(n.fn.Param) < 1 || len(n.fn.Param) > 2 {
return errors.Errorf("CreateTracker has unexpected number of parameters: %v", len(n.fn.Param))
}
n.call = func() (rt sdf.RTracker, err error) {
ret := n.fn.Fn.Call(n.args)
switch len(ret) {
case 1:
return ret[0].(sdf.RTracker), nil
case 2:
return ret[0].(sdf.RTracker), asError(ret[1])
}
panic(fmt.Sprintf("CreateTracker has unexpected number of return values: %v", len(ret)))
}
}
return nil
}View on GitHub (pinned to 12126d8942)
Solutions
- Give CreateTracker 1-2 parameters, e.g. func(rest R) sdf.RTracker.
- Remove unsupported parameters such as context.Context.
- Return a concrete *RTracker implementation (a type satisfying sdf.RTracker) — the return type is validated separately.
- Verify with a small beam.TestPipeline run that the DoFn validates end to end.
Example fix
// before
func (fn *mySdf) CreateTracker(ctx context.Context, rest watermarksInterval) *myTracker { ... }
// after
func (fn *mySdf) CreateTracker(rest watermarksInterval) *myTracker { ... } Defensive patterns
Strategy: validation
Validate before calling
t := reflect.TypeOf(fn.CreateTracker)
n := t.NumIn()
if n < 1 || n > 2 {
return fmt.Errorf("CreateTracker must take 1-2 parameters, has %d", n)
} Try / catch
if err != nil {
if strings.Contains(err.Error(), "CreateTracker has unexpected number of parameters") {
// fix arity to 1-2
}
return err
} Prevention
- Use func(rest R) sdf.RTracker as the canonical CreateTracker shape.
- Return a type that satisfies sdf.RTracker.
- Validate the whole SDF signature set in a unit test before running on a runner.
When it happens
Trigger: Registering a CreateTracker fn with 0 parameters or 3+ parameters, e.g. func() sdf.RTracker or func(rest R, el T, ts typex.EventTime) sdf.RTracker; the default validation at sdf_invokers_arity.go:254 fires.
Common situations: Defining CreateTracker with no restriction parameter after refactoring, or adding a context.Context parameter which this hook does not support.
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
- CreateWatermarkEstimator fn %v has unexpected number of para
- InitialWatermarkEstimatorState fn %v has unexpected number o
- WatermarkEstimatorState fn %v has unexpected number of param
- CreateInitialRestriction has unexpected number of parameters
- SplitRestriction has unexpected number of parameters: %v
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/eb64d0b96da20892.
Report an issue: GitHub.