{"record":{"id":"472f4db7d6014dcb","repo":"apache/beam","slug":"createinitialrestriction-has-unexpected-number-of-parameters","errorCode":null,"errorMessage":"CreateInitialRestriction has unexpected number of parameters: %v","messagePattern":"CreateInitialRestriction 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":74,"sourceCode":"\t\t\tr0, r1 := fnT.Call1x2(n.args[0])\n\t\t\treturn r0, asError(r1)\n\t\t}\n\n\tcase reflectx.Func2x2:\n\t\tn.call = func() (rest any, err error) {\n\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() (rest 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\tdefault:\n\t\tif len(n.fn.Param) < 1 || len(n.fn.Param) > 3 {\n\t\t\treturn errors.Errorf(\"CreateInitialRestriction has unexpected number of parameters: %v\", len(n.fn.Param))\n\t\t}\n\n\t\tn.call = func() (rest 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(\"CreateInitialRestriction has unexpected number of return values: %v\", len(ret)))\n\t\t}\n\t}\n\n\treturn nil\n}","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/sdf_invokers_arity.go#L56-L92","documentation":"The CreateInitialRestriction function of an SDF must take between 1 and 3 parameters (element, and optionally timestamp and/or restriction-related inputs). initCallFn in sdf_invokers_arity.go rejects any other arity with this error during invoker setup. Fast-path implementations exist for common arities; anything else falls to the default validation.","triggerScenarios":"Registering a CreateInitialRestriction fn with 0 parameters or 4+ parameters, e.g. func() R or func(ctx context.Context, el T, ts typex.EventTime, w W) R. Raised by newCreateInitialRestrictionInvoker when building the DoFn's reflection invoker.","commonSituations":"Adding a context.Context first parameter (not supported for this hook), or defining the method with no parameters at all, usually after refactoring a DoFn.","solutions":["Give CreateInitialRestriction 1-3 parameters, typically func(el T) R (optionally + typex.EventTime, + a second input).","Remove unsupported parameters such as context.Context from the signature.","Capture needed configuration in the DoFn struct rather than via extra parameters.","Check the signature against the sdf package's documented CreateInitialRestriction forms."],"exampleFix":"// before\nfunc (fn *mySdf) CreateInitialRestriction(ctx context.Context, el string) watermarksInterval { ... }\n// after\nfunc (fn *mySdf) CreateInitialRestriction(el string) watermarksInterval { ... }","handlingStrategy":"validation","validationCode":"t := reflect.TypeOf(fn.CreateInitialRestriction)\nn := t.NumIn()\nif n < 1 || n > 3 {\n    return fmt.Errorf(\"CreateInitialRestriction must take 1-3 parameters, has %d\", n)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"CreateInitialRestriction has unexpected number of parameters\") {\n        // fix arity to 1-3\n    }\n    return err\n}","preventionTips":["Use func(el T) R as the canonical CreateInitialRestriction shape.","Never add context.Context to SDF lifecycle hooks unless documented.","Match parameter lists across CreateInitialRestriction/SplitRestriction/RestrictionSize."],"tags":["go","beam","sdf","restriction","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"}