{"record":{"id":"34acbf3bdd603db1","repo":"apache/beam","slug":"initialwatermarkestimatorstate-fn-v-has-unexpected-number-of","errorCode":null,"errorMessage":"InitialWatermarkEstimatorState fn %v has unexpected number of parameters: %v","messagePattern":"InitialWatermarkEstimatorState 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":455,"sourceCode":"\tdefault:\n\t\tswitch len(n.fn.Param) {\n\t\tcase 3:\n\t\t\tn.call = func(rest any, elms *FullValue) any {\n\t\t\t\tn.args[0] = elms.Timestamp\n\t\t\t\tn.args[1] = rest\n\t\t\t\tn.args[2] = elms.Elm\n\t\t\t\treturn n.fn.Fn.Call(n.args)[0]\n\t\t\t}\n\t\tcase 4:\n\t\t\tn.call = func(rest any, elms *FullValue) any {\n\t\t\t\tn.args[0] = elms.Timestamp\n\t\t\t\tn.args[1] = rest\n\t\t\t\tn.args[2] = elms.Elm\n\t\t\t\tn.args[3] = elms.Elm2\n\t\t\t\treturn n.fn.Fn.Call(n.args)[0]\n\t\t\t}\n\t\tdefault:\n\t\t\treturn errors.Errorf(\"InitialWatermarkEstimatorState 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 InitialWatermarkEstimatorState given a restriction and returns an sdf.RTracker.\nfunc (n *iwesInvoker) Invoke(rest any, elms *FullValue) any {\n\treturn n.call(rest, elms)\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 *iwesInvoker) Reset() {\n\tfor i := range n.args {\n\t\tn.args[i] = nil\n\t}\n}","sourceCodeStart":437,"sourceCodeEnd":473,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/sdf_invokers.go#L437-L473","documentation":"The InitialWatermarkEstimatorState function of an SDF must match a supported signature; the reflection invoker only implements specific arities. If the function has an unsupported number of parameters, initCallFn returns this error during invoker construction (newCreateWatermarkEstimatorInvoker setup).","triggerScenarios":"Registering an InitialWatermarkEstimatorState fn with a signature outside the supported forms, e.g. taking 3+ parameters or an odd combination of watermark state, timestamp, element, and restriction. The supported call paths pass at most (state, ts, elms...) and the default case errors at sdf_invokers.go:455.","commonSituations":"Developers adding an extra context or config parameter to InitialWatermarkEstimatorState, or mixing up the ordering so the reflected signature no longer matches any generated case.","solutions":["Match InitialWatermarkEstimatorState to a supported signature such as func(wstate W, ts typex.EventTime, rest R, el T) W or its smaller arities.","Remove extra parameters not part of the documented signature set.","Pass auxiliary configuration via the DoFn struct fields instead of extra function parameters.","Compare against the sdf package docs/examples for InitialWatermarkEstimatorState."],"exampleFix":"// before\nfunc (fn *mySdf) InitialWatermarkEstimatorState(ctx context.Context, wstate W, ts typex.EventTime) W { ... }\n// after\nfunc (fn *mySdf) InitialWatermarkEstimatorState(wstate W, ts typex.EventTime) W { ... }","handlingStrategy":"validation","validationCode":"t := reflect.TypeOf(fn.InitialWatermarkEstimatorState)\nif t.NumIn() > 4 {\n    return fmt.Errorf(\"InitialWatermarkEstimatorState has unsupported arity %d\", t.NumIn())\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"InitialWatermarkEstimatorState fn\") {\n        // align the signature with a supported form\n    }\n    return err\n}","preventionTips":["Copy signatures verbatim from sdf package examples.","Avoid adding context/config parameters to SDF watermark hooks.","Validate DoFn signatures in tests before deployment."],"tags":["go","beam","sdf","watermark","arity"],"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"}