{"record":{"id":"995fd7d557907e14","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-995fd7","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 0 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 7 inputs and 0 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1500,"sourceCode":"}\n\nfunc (c *shimFunc7x0) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc7x0) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc7x0) Call7x0(arg0, arg1, arg2, arg3, arg4, arg5, arg6 any) {\n\tret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4, arg5, arg6})\n\t_ = ret\n\treturn\n}\n\nfunc ToFunc7x0(c Func) Func7x0 {\n\tif c.Type().NumIn() != 7 || c.Type().NumOut() != 0 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 0 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func7x0); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc7x0{inner: c}\n}\n\nfunc MakeFunc7x0(fn any) Func7x0 {\n\treturn ToFunc7x0(MakeFunc(fn))\n}\n\ntype Func7x1 interface {\n\tFunc\n\tCall7x1(any, any, any, any, any, any, any) any\n}\n\ntype shimFunc7x1 struct {\n\tinner Func","sourceCodeStart":1482,"sourceCodeEnd":1518,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1482-L1518","documentation":"reflectx.ToFunc7x0 adapts a Func into a 7-input/0-output (sink-style) function. It panics if the wrapped function does not have exactly 7 inputs and 0 outputs, since the shim can only forward arguments of matching arity. The panic fires at registration time, not at pipeline runtime.","triggerScenarios":"Calling ToFunc7x0 (or MakeFunc7x0) with a Func whose signature has inputs != 7 or any return values at all (e.g. a 7-in/1-out function that returns an error).","commonSituations":"Sink/emit functions that were given an error return value during refactoring; passing a 6-input variant when a 7th context/collector parameter was required; reusing a helper built for another slot count.","solutions":["Change the function to take exactly 7 parameters and return nothing","If the function must return something, use the matching ToFunc7xN converter instead","Use the correct arity converter (e.g. ToFunc6x0) if 7 inputs is wrong","Guard conversions with an arity check before calling to convert the panic into a controlled error"],"exampleFix":"// before\nfunc(a, b, c, d, e, f2, g any) error { return nil } // 7 in, 1 out\nreflectx.ToFunc7x0(reflectx.NewFunc(fn)) // panics\n// after\nfunc(a, b, c, d, e, f2, g any) {} // 7 in, 0 out\nreflectx.ToFunc7x0(reflectx.NewFunc(fn)) // OK","handlingStrategy":"validation","validationCode":"t := f.Type()\nif t.NumIn() != 7 || t.NumOut() != 0 {\n    return fmt.Errorf(\"ToFunc7x0 needs 7 in / 0 out, got %d in / %d out (%v)\", t.NumIn(), t.NumOut(), t)\n}","typeGuard":"func isFunc7x0(f reflectx.Func) bool {\n    t := f.Type()\n    return t.NumIn() == 7 && t.NumOut() == 0\n}","tryCatchPattern":"func safeToFunc7x0(f reflectx.Func) (fn reflectx.Func7x0, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"conversion failed: %v\", r)\n        }\n    }()\n    fn = reflectx.ToFunc7x0(f)\n    return\n}","preventionTips":["Sinks must return nothing; drop the error return or switch to a Nx1 converter","Verify input count after adding context/emitter parameters","Use MakeFunc7x0 with a directly typed function for compile-time safety","Test converter calls at pipeline-construction time"],"tags":["go","apache-beam","reflection","function-arity","panic"],"backgroundTag":"type-mismatch","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"}