{"record":{"id":"efdf8c9ba115240a","repo":"apache/beam","slug":"unexpected-number-of-parameters-in-method-v-got-v-want","errorCode":null,"errorMessage":"unexpected number of parameters in method %v. got: %v, want number in range: 0 to 1. Check that the signature conforms to the expected signature for %v.","messagePattern":"unexpected number of parameters in method (.+?)\\. got: (.+?), want number in range: 0 to 1\\. Check that the signature conforms to the expected signature for (.+?)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/fn.go","lineNumber":1183,"sourceCode":"\t\t\tprocessElementName, pos)\n\t\treturn false, errors.SetTopLevelMsgf(err, \"Method %v has an sdf.WatermarkEstimator parameter at index %v, \"+\n\t\t\t\"but is not part of a watermark estimating DoFn. sdf.WatermarkEstimator is invalid in %v in \"+\n\t\t\t\"non-watermark estimating DoFns.\",\n\t\t\tprocessElementName, pos, processElementName)\n\t}\n\n\treturn isWatermarkEstimating, nil\n}\n\n// validateWatermarkSig validates that all watermark related functions are valid\nfunc validateWatermarkSig(fn *Fn, numMainIn int) error {\n\treturnNum := 1 // TODO(BEAM-3301): Enable optional error params in SDF methods.\n\n\twatermarkEstimatorT := reflect.TypeOf((*sdf.WatermarkEstimator)(nil)).Elem()\n\tmethod := fn.methods[createWatermarkEstimatorName]\n\n\tif len(method.Param) > 1 {\n\t\terr := errors.Errorf(\"unexpected number of params in method %v. got: %v, want number in range: 0 to 1\",\n\t\t\tcreateWatermarkEstimatorName, len(method.Param))\n\t\treturn errors.SetTopLevelMsgf(err, \"unexpected number of parameters in method %v. \"+\n\t\t\t\"got: %v, want number in range: 0 to 1. Check that the signature conforms to the expected signature for %v.\",\n\t\t\tcreateWatermarkEstimatorName, len(method.Param), createWatermarkEstimatorName)\n\t} else if len(method.Param) == 1 {\n\t\terr := validateStatefulWatermarkSig(fn, numMainIn)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t} else {\n\t\tif _, ok := fn.methods[initialWatermarkEstimatorStateName]; ok {\n\t\t\terr := errors.Errorf(\"stateful watermark estimation method %v is present, \"+\n\t\t\t\t\"but CreateWatermarkEstimator doesn't take in a state parameter.\", initialWatermarkEstimatorStateName)\n\t\t\treturn err\n\t\t}\n\t\tif _, ok := fn.methods[watermarkEstimatorStateName]; ok {\n\t\t\terr := errors.Errorf(\"stateful watermark estimation method %v is present, \"+\n\t\t\t\t\"but CreateWatermarkEstimator doesn't take in a state parameter.\", watermarkEstimatorStateName)","sourceCodeStart":1165,"sourceCodeEnd":1201,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/fn.go#L1165-L1201","documentation":"The CreateWatermarkEstimator method accepts 0 or 1 parameters (at most one, e.g. an initial estimator state). Beam rejects the DoFn when the method declares more than one parameter, telling you to match the expected signature.","triggerScenarios":"Defining CreateWatermarkEstimator with two or more parameters, e.g. CreateWatermarkEstimator(state StateT, config ConfigT) int64.","commonSituations":"Passing extra context/config arguments by mistake; misunderstanding which arguments Beam injects into creator methods.","solutions":["Reduce CreateWatermarkEstimator to at most one parameter: either no parameters or exactly the initial state type InitialWatermarkEstimatorState() returns.","Move any extra configuration into the DoFn's fields rather than method parameters.","If you want a stateful estimator, also define InitialWatermarkEstimatorState and WatermarkEstimatorState methods consistently."],"exampleFix":"// before\nfunc (fn *f) CreateWatermarkEstimator(state StateT, cfg Cfg) *myEstimator {...}\n// after\nfunc (fn *f) CreateWatermarkEstimator(state StateT) *myEstimator {...}","handlingStrategy":"validation","validationCode":"func wmCreatorArity(fn interface{}) error {\n    m, ok := reflect.TypeOf(fn).MethodByName(\"CreateWatermarkEstimator\")\n    if ok && m.Type.NumIn() > 2 { // receiver + params\n        return fmt.Errorf(\"CreateWatermarkEstimator has %d params, want 0 or 1\", m.Type.NumIn()-1)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["CreateWatermarkEstimator takes either nothing or exactly the initial state; inject config via struct fields.","Copy signatures from the sdf package docs/examples rather than writing them freehand."],"tags":["go","apache-beam","watermark","validation"],"backgroundTag":"invalid-argument-count","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}