apache/beam · critical

CreateTracker has unexpected number of parameters

Error message

CreateTracker has unexpected number of parameters: %v

What it means

This panic comes from the generated SDF invoker code in the Beam Go SDK. When a splittable DoFn's CreateTracker method has a signature whose parameter count is outside the 1-2 range the framework supports (1 param: restriction, or 2 params: restriction + element), the exec runtime cannot build a caller for it and panics.

Solutions

  1. Change CreateTracker to accept exactly 1 parameter (the restriction) or 2 parameters (restriction and element)
  2. Verify the function is actually a splittable DoFn and the method name/signature matches the SDF contract
  3. Check the Beam Go SDK docs for supported CreateTracker signatures for your version
  4. If you need extra data, capture it in the DoFn struct instead of adding parameters

Example fix

// before
func (fn *mySDF) CreateTracker(rest, elem myRestriction, ctx context.Context) myTracker { ... }
// after
func (fn *mySDF) CreateTracker(rest myRestriction, elem myElem) myTracker { ... }
Defensive patterns

Strategy: validation

Validate before calling

n := reflect.TypeOf(fn).NumMethod()
m, _ := reflect.TypeOf(fn).MethodByName("CreateTracker")
if m == nil || m.Type.NumIn() < 2 || m.Type.NumIn() > 3 {
	return errors.New("CreateTracker must take 1 or 2 parameters")
}

Type guard

func validCreateTracker(fn interface{}) bool {
	m, ok := reflect.TypeOf(fn).MethodByName("CreateTracker")
	return ok && m.Type.NumIn() >= 2 && m.Type.NumIn() <= 3
}

Prevention

When it happens

Trigger: Registering a splittable DoFn whose CreateTracker method takes 0 parameters, or 3+ parameters (e.g. restriction + element + extra context param), then executing the pipeline so the generated arity-dispatch code hits its default branch.

Common situations: Refactoring CreateTracker to add a context or bookkeeping parameter; copying a DoFn skeleton and accidentally changing the signature; typos so the method no longer matches the expected SDF shape.

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/036399e48be5d9c1. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/core/runtime/exec/sdf_invokers_arity.tmpl:184

{{range $in := upto 3}}
    {{if gt $out 0}}
    {{if gt $in 0}}
	case reflectx.Func{{$in}}x{{$out}}:
		n.call = func() (rt sdf.RTracker, err error) {
			{{mktuplef $out "r%v"}} := fnT.Call{{$in}}x{{$out}}({{mktuplef $in "n.args[%v]"}})
			{{- if eq $out 1}}
			return r0.(sdf.RTracker), nil
			{{- else}}
			return r0.(sdf.RTracker), asError(r1)
			{{- end}}
		}
	{{end}}
	{{end}}
{{end}}
{{end}}
	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)