{"record":{"id":"0bd9ba869c088c29","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-0bd9ba","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 0 inputs and 3 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 0 inputs and 3 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":188,"sourceCode":"}\n\nfunc (c *shimFunc0x3) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc0x3) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc0x3) Call0x3() (any, any, any) {\n\tret := c.inner.Call([]any{})\n\t_ = ret\n\treturn ret[0], ret[1], ret[2]\n}\n\nfunc ToFunc0x3(c Func) Func0x3 {\n\tif c.Type().NumIn() != 0 || c.Type().NumOut() != 3 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 0 inputs and 3 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func0x3); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc0x3{inner: c}\n}\n\nfunc MakeFunc0x3(fn any) Func0x3 {\n\treturn ToFunc0x3(MakeFunc(fn))\n}\n\ntype Func0x4 interface {\n\tFunc\n\tCall0x4() (any, any, any, any)\n}\n\ntype shimFunc0x4 struct {\n\tinner Func","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L170-L206","documentation":"reflectx.ToFunc0x3 adapts a Func to Func0x3 (0 inputs, 3 outputs) and panics unless the reflect type has exactly 0 inputs and 3 outputs. The panic message reports the actual function type with its input and output counts.","triggerScenarios":"Calling ToFunc0x3 or MakeFunc0x3 with a func whose signature is not func() (A, B, C) — e.g. func() (A, B) (two returns) or func(ctx, x) (A, B, C) (inputs present).","commonSituations":"Switching a generator from three returns to two (e.g. dropping the error) without changing the adapter; wrapping a function with receiver-bound parameters that appear as extra inputs in the reflect type.","solutions":["Use ToFunc0x2 if the function now returns only two values.","Ensure the function is a plain closure with zero parameters and exactly three returns.","Verify with fn.Type().NumIn() and fn.Type().NumOut() before choosing the adapter, and pick the matching ToFuncNxx."],"exampleFix":"// before\nreflectx.ToFunc0x3(reflectx.MakeFunc(func() (int, int) { ... }))\n// after\nreflectx.ToFunc0x2(reflectx.MakeFunc(func() (int, int) { ... }))","handlingStrategy":"validation","validationCode":"func isFunc0x3(fn reflectx.Func) bool {\n    return fn.Type().NumIn() == 0 && fn.Type().NumOut() == 3\n}","typeGuard":"func asFunc0x3(fn reflectx.Func) (reflectx.Func0x3, bool) {\n    if f, ok := fn.(reflectx.Func0x3); ok { return f, true }\n    return nil, false\n}","tryCatchPattern":"func safeToFunc0x3(fn reflectx.Func) (f reflectx.Func0x3, err error) {\n    defer func() {\n        if r := recover(); r != nil { err = fmt.Errorf(\"ToFunc0x3: %v\", r) }\n    }()\n    return reflectx.ToFunc0x3(fn), nil\n}","preventionTips":["Ensure the closure has zero parameters and three returns.","Bound methods can add inputs — convert via a closure with an empty parameter list.","Confirm NumIn/NumOut before selecting the adapter variant."],"tags":["go","apache-beam","reflectx","panic","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"}