{"record":{"id":"6d3c869c37b91a25","repo":"apache/beam","slug":"restrictionsize-has-unexpected-number-of-parameters-v","errorCode":null,"errorMessage":"RestrictionSize has unexpected number of parameters: %v","messagePattern":"RestrictionSize has unexpected number of parameters: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/exec/sdf_invokers_arity.go","lineNumber":202,"sourceCode":"\t\t\tr0, r1 := fnT.Call2x2(n.args[0], n.args[1])\n\t\t\treturn r0.(float64), asError(r1)\n\t\t}\n\n\tcase reflectx.Func3x2:\n\t\tn.call = func() (size float64, err error) {\n\t\t\tr0, r1 := fnT.Call3x2(n.args[0], n.args[1], n.args[2])\n\t\t\treturn r0.(float64), asError(r1)\n\t\t}\n\n\tcase reflectx.Func4x2:\n\t\tn.call = func() (size float64, err error) {\n\t\t\tr0, r1 := fnT.Call4x2(n.args[0], n.args[1], n.args[2], n.args[3])\n\t\t\treturn r0.(float64), asError(r1)\n\t\t}\n\n\tdefault:\n\t\tif len(n.fn.Param) < 2 || len(n.fn.Param) > 4 {\n\t\t\treturn errors.Errorf(\"RestrictionSize has unexpected number of parameters: %v\", len(n.fn.Param))\n\t\t}\n\n\t\tn.call = func() (size float64, err error) {\n\t\t\tret := n.fn.Fn.Call(n.args)\n\n\t\t\tswitch len(ret) {\n\t\t\tcase 1:\n\t\t\t\treturn ret[0].(float64), nil\n\t\t\tcase 2:\n\t\t\t\treturn ret[0].(float64), asError(ret[1])\n\t\t\t}\n\n\t\t\tpanic(fmt.Sprintf(\"RestrictionSize has unexpected number of return values: %v\", len(ret)))\n\t\t}\n\t}\n\n\treturn nil\n}","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/sdf_invokers_arity.go#L184-L220","documentation":"The RestrictionSize function of an SDF must take between 2 and 4 parameters (restriction plus element/timestamp inputs) and return a float64. initCallFn rejects other arities with this error during invoker setup, since sizing needs the restriction and its inputs to compute a size.","triggerScenarios":"Registering a RestrictionSize fn with fewer than 2 parameters (e.g. only the restriction) or more than 4, hitting the default validation at sdf_invokers_arity.go:202 when the fast paths don't match.","commonSituations":"Writing a size function taking only the restriction for simplicity, or mirroring a different SDK's signature; also occurs when the tracker parameter is mistakenly included/omitted relative to the supported forms.","solutions":["Give RestrictionSize 2-4 parameters, e.g. func(el T, rest R) float64.","Ensure the signature mirrors SplitRestriction's parameter shape so both validate.","Remove or add parameters to fall within the 2-4 arity range.","Consult the sdf package size-function examples when in doubt."],"exampleFix":"// before\nfunc (fn *mySdf) RestrictionSize(rest watermarksInterval) float64 { ... }\n// after\nfunc (fn *mySdf) RestrictionSize(el string, rest watermarksInterval) float64 { ... }","handlingStrategy":"validation","validationCode":"t := reflect.TypeOf(fn.RestrictionSize)\nn := t.NumIn()\nif n < 2 || n > 4 {\n    return fmt.Errorf(\"RestrictionSize must take 2-4 parameters, has %d\", n)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"RestrictionSize has unexpected number of parameters\") {\n        // fix arity to 2-4\n    }\n    return err\n}","preventionTips":["Use func(el T, rest R) float64 as the canonical size signature.","Keep size/split signatures consistent with each other.","Confirm the function returns float64, not int."],"tags":["go","beam","sdf","sizing","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"}