{"record":{"id":"1c64b01fa97c6247","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-1c64b0","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 5 inputs and 0 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 5 inputs and 0 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1090,"sourceCode":"}\n\nfunc (c *shimFunc5x0) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc5x0) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc5x0) Call5x0(arg0, arg1, arg2, arg3, arg4 any) {\n\tret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4})\n\t_ = ret\n\treturn\n}\n\nfunc ToFunc5x0(c Func) Func5x0 {\n\tif c.Type().NumIn() != 5 || c.Type().NumOut() != 0 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 5 inputs and 0 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func5x0); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc5x0{inner: c}\n}\n\nfunc MakeFunc5x0(fn any) Func5x0 {\n\treturn ToFunc5x0(MakeFunc(fn))\n}\n\ntype Func5x1 interface {\n\tFunc\n\tCall5x1(any, any, any, any, any) any\n}\n\ntype shimFunc5x1 struct {\n\tinner Func","sourceCodeStart":1072,"sourceCodeEnd":1108,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1072-L1108","documentation":"reflectx.ToFunc5x0 wraps a reflectx.Func into a Func5x0 (5 inputs, no return values). It panics with this message if the wrapped func's reflect.Type does not have exactly 5 inputs and 0 outputs. This guarantees the fast-path shim can call the function without type or arity errors.","triggerScenarios":"Calling reflectx.ToFunc5x0(c) where c.Type().NumIn() != 5 or c.Type().NumOut() != 0. E.g. registering a sink-like function that returns values, or one that takes fewer/more than 5 arguments.","commonSituations":"Sink/consumer DoFns that accidentally return a value; passing a 5-input function with an error return into a ToFunc5x0 conversion; copy-pasted registration using the wrong ToFuncNxM helper after changing input count.","solutions":["Make the function take exactly 5 inputs and return nothing (drop or move any return values).","Switch to the correct ToFuncN x M helper matching the real signature, e.g. ToFunc5x1 for a single error return.","Verify the DoFn's ProcessElement signature matches the 5x0 shape expected by the pipeline step."],"exampleFix":"// before\nfunc fn(a A, b B, c C, d D, e E) error { ... }\nreflectx.ToFunc5x0(fn) // panics: 1 output\n\n// after\nfunc fn(a A, b B, c C, d D, e E) { ... }\nreflectx.ToFunc5x0(fn)","handlingStrategy":"validation","validationCode":"fn := reflect.TypeOf(fnAny)\nif fn.Kind() == reflect.Func && fn.NumIn() == 5 && fn.NumOut() == 0 {\n    _ = reflectx.ToFunc5x0(fnAny)\n}","typeGuard":"func isFunc5x0(f interface{}) bool {\n    t := reflect.TypeOf(f)\n    return t != nil && t.Kind() == reflect.Func && t.NumIn() == 5 && t.NumOut() == 0\n}","tryCatchPattern":"func safeToFunc5x0(c reflectx.Func) (f reflectx.Func5x0, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"ToFunc5x0 failed: %v\", r)\n        }\n    }()\n    return reflectx.ToFunc5x0(c), nil\n}","preventionTips":["Sink functions must return nothing; drop stray error returns or switch to ToFunc5x1.","Keep signature changes and registration helper changes in the same commit.","Write a smoke test that wraps each user function before pipeline submission.","Use beam.TryParDo-style generic registration when possible to avoid fixed-arity helpers."],"tags":["go","apache-beam","reflection","function-signature"],"backgroundTag":"type-mismatch","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"}