{"record":{"id":"d287e6ece139c167","repo":"apache/beam","slug":"createwatermarkestimator-fn-v-has-unexpected-number-of","errorCode":null,"errorMessage":"CreateWatermarkEstimator fn %v has unexpected number of parameters: %v","messagePattern":"CreateWatermarkEstimator fn (.+?) has unexpected number of parameters: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/exec/sdf_invokers.go","lineNumber":376,"sourceCode":"\t\t\treturn fnT.Call0x1().(sdf.WatermarkEstimator)\n\t\t}\n\tcase reflectx.Func1x1:\n\t\tn.call = func(rest any) sdf.WatermarkEstimator {\n\t\t\treturn fnT.Call1x1(rest).(sdf.WatermarkEstimator)\n\t\t}\n\tdefault:\n\t\tswitch len(n.fn.Param) {\n\t\tcase 0:\n\t\t\tn.call = func(rest any) sdf.WatermarkEstimator {\n\t\t\t\treturn n.fn.Fn.Call(n.args)[0].(sdf.WatermarkEstimator)\n\t\t\t}\n\t\tcase 1:\n\t\t\tn.call = func(rest any) sdf.WatermarkEstimator {\n\t\t\t\tn.args[0] = rest\n\t\t\t\treturn n.fn.Fn.Call(n.args)[0].(sdf.WatermarkEstimator)\n\t\t\t}\n\t\tdefault:\n\t\t\treturn errors.Errorf(\"CreateWatermarkEstimator fn %v has unexpected number of parameters: %v\",\n\t\t\t\tn.fn.Fn.Name(), len(n.fn.Param))\n\t\t}\n\t}\n\treturn nil\n}\n\n// Invoke calls CreateWatermarkEstimator given a restriction and returns an sdf.WatermarkEstimator.\nfunc (n *cweInvoker) Invoke(rest any) sdf.WatermarkEstimator {\n\treturn n.call(rest)\n}\n\n// Reset zeroes argument entries in the cached slice to allow values to be\n// garbage collected after the bundle ends.\nfunc (n *cweInvoker) Reset() {\n\tfor i := range n.args {\n\t\tn.args[i] = nil\n\t}\n}","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/sdf_invokers.go#L358-L394","documentation":"When wiring up a CreateWatermarkEstimator function for an SDF, the invoker validates the function's arity. Only 0- or 1-parameter signatures are supported (e.g. func(rest) sdf.WatermarkEstimator); anything else fails at initCallFn with this error. It is raised by newCreateWatermarkEstimatorInvoker during plan construction, before any data flows.","triggerScenarios":"Registering a CreateWatermarkEstimatorFn whose signature has 2 or more parameters, e.g. func(rest R, el T) sdf.WatermarkEstimator. The reflection-based invoker only builds call paths for 0 or 1 params and hits the default error case at sdf_invokers.go:376.","commonSituations":"Developers copying the shape of ProcessElement (which takes element+restriction) into CreateWatermarkEstimator, or adding a context parameter that this hook does not accept.","solutions":["Change CreateWatermarkEstimator to accept at most one parameter (the restriction).","Use a no-parameter form func() sdf.WatermarkEstimator if no restriction data is needed.","Move extra values (element, context) into the estimator's state or a struct captured at DoFn construction time.","Check the Beam SDF watermark estimator signature docs for the supported forms."],"exampleFix":"// before\nfunc (fn *mySdf) CreateWatermarkEstimator(rt *rangeTracker, el string) sdf.WatermarkEstimator { ... }\n// after\nfunc (fn *mySdf) CreateWatermarkEstimator(rt *rangeTracker) sdf.WatermarkEstimator { ... }","handlingStrategy":"validation","validationCode":"t := reflect.TypeOf(fn.CreateWatermarkEstimator)\nif t.NumIn() > 1 {\n    return fmt.Errorf(\"CreateWatermarkEstimator must take at most 1 parameter, has %d\", t.NumIn())\n}","typeGuard":null,"tryCatchPattern":"if err := beam.RunWithExporter(...); err != nil {\n    if strings.Contains(err.Error(), \"CreateWatermarkEstimator fn\") {\n        // correct the function signature\n    }\n    return err\n}","preventionTips":["Follow documented CreateWatermarkEstimator signatures (0 or 1 param).","Pass extra data via DoFn struct fields, not parameters.","Run signature-validating unit tests before submitting jobs."],"tags":["go","beam","sdf","watermark","arity"],"backgroundTag":"missing-required-argument","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"}