{"record":{"id":"2a98f47edc731324","repo":"apache/beam","slug":"splitrestriction-has-unexpected-number-of-parameters-v","errorCode":null,"errorMessage":"SplitRestriction has unexpected number of parameters: %v","messagePattern":"SplitRestriction 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":138,"sourceCode":"\t\t\tr0, r1 := fnT.Call2x2(n.args[0], n.args[1])\n\t\t\treturn r0, asError(r1)\n\t\t}\n\n\tcase reflectx.Func3x2:\n\t\tn.call = func() (splits any, err error) {\n\t\t\tr0, r1 := fnT.Call3x2(n.args[0], n.args[1], n.args[2])\n\t\t\treturn r0, asError(r1)\n\t\t}\n\n\tcase reflectx.Func4x2:\n\t\tn.call = func() (splits any, 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, 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(\"SplitRestriction has unexpected number of parameters: %v\", len(n.fn.Param))\n\t\t}\n\n\t\tn.call = func() (splits any, 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], nil\n\t\t\tcase 2:\n\t\t\t\treturn ret[0], asError(ret[1])\n\t\t\t}\n\n\t\t\tpanic(fmt.Sprintf(\"SplitRestriction has unexpected number of return values: %v\", len(ret)))\n\t\t}\n\t}\n\n\treturn nil\n}","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/sdf_invokers_arity.go#L120-L156","documentation":"The SplitRestriction function of an SDF must take between 2 and 4 parameters (element plus optional timestamp/etc., matching CreateInitialRestriction's inputs plus the restriction). initCallFn rejects any other arity with this error. The reported 'called by' newCreateInitialRestrictionInvoker reflects that all SDF invokers share the same init wiring.","triggerScenarios":"Registering a SplitRestriction fn with fewer than 2 parameters (e.g. only the restriction) or more than 4, so no generated fast path matches and the default case errors at sdf_invokers_arity.go:138.","commonSituations":"Omitting the element parameter when writing a stateless splitter, or adding extra config parameters after refactoring; also happens when parameter types don't match so the reflected signature is treated as unknown arity.","solutions":["Give SplitRestriction 2-4 parameters, e.g. func(el T, rest R) []R.","Always include the element (and any timestamp parameter matching CreateInitialRestriction) in the signature.","Remove extra parameters beyond the documented set.","Unit-test the SDF with beam.TestPipeline so signature errors surface before deployment."],"exampleFix":"// before\nfunc (fn *mySdf) SplitRestriction(rest watermarksInterval) []watermarksInterval { ... }\n// after\nfunc (fn *mySdf) SplitRestriction(el string, rest watermarksInterval) []watermarksInterval { ... }","handlingStrategy":"validation","validationCode":"t := reflect.TypeOf(fn.SplitRestriction)\nn := t.NumIn()\nif n < 2 || n > 4 {\n    return fmt.Errorf(\"SplitRestriction must take 2-4 parameters, has %d\", n)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"SplitRestriction has unexpected number of parameters\") {\n        // fix arity to 2-4, element first\n    }\n    return err\n}","preventionTips":["Always include the element parameter in SplitRestriction.","Mirror the parameter list of CreateInitialRestriction plus the restriction.","Run a local TestPipeline smoke test for every new SDF."],"tags":["go","beam","sdf","splitting","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"}