{"record":{"id":"d08955b41f9dce20","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-d08955","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 8 inputs and 0 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 8 inputs and 0 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1705,"sourceCode":"}\n\nfunc (c *shimFunc8x0) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc8x0) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc8x0) Call8x0(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 any) {\n\tret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7})\n\t_ = ret\n\treturn\n}\n\nfunc ToFunc8x0(c Func) Func8x0 {\n\tif c.Type().NumIn() != 8 || c.Type().NumOut() != 0 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 8 inputs and 0 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func8x0); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc8x0{inner: c}\n}\n\nfunc MakeFunc8x0(fn any) Func8x0 {\n\treturn ToFunc8x0(MakeFunc(fn))\n}\n\ntype Func8x1 interface {\n\tFunc\n\tCall8x1(any, any, any, any, any, any, any, any) any\n}\n\ntype shimFunc8x1 struct {\n\tinner Func","sourceCodeStart":1687,"sourceCodeEnd":1723,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1687-L1723","documentation":"reflectx.ToFunc8x0 adapts a Func as an 8-input/0-output (sink) function and panics if the wrapped signature differs. Any return values or a different input count trigger the panic because shimFunc8x0 performs a bare forwarding call. The message shows got vs want counts.","triggerScenarios":"Calling ToFunc8x0 (or MakeFunc8x0) with a Func having inputs != 8 or any outputs (e.g. an 8-in/1-out function returning error).","commonSituations":"Sinks gaining an error return during refactors; an extra context/emitter parameter added or removed (7<->8 inputs) without swapping converters; reusing registration boilerplate from another stage.","solutions":["Make the function take exactly 8 parameters and return nothing","If it returns values, use ToFunc8x1..ToFunc8xN as appropriate","Use the correct input-count converter if 8 is wrong (e.g. ToFunc7x0)","Catch or pre-check arity in dynamic registration paths"],"exampleFix":"// before\nfunc(a, b, c, d, e, f2, g, h any) error { return nil } // 1 output\nreflectx.ToFunc8x0(reflectx.NewFunc(fn)) // panics\n// after\nfunc(a, b, c, d, e, f2, g, h any) {} // 0 outputs\nreflectx.ToFunc8x0(reflectx.NewFunc(fn)) // OK","handlingStrategy":"validation","validationCode":"t := f.Type()\nif t.NumIn() != 8 || t.NumOut() != 0 {\n    return fmt.Errorf(\"ToFunc8x0 needs 8 in / 0 out, got %d in / %d out (%v)\", t.NumIn(), t.NumOut(), t)\n}","typeGuard":"func isFunc8x0(f reflectx.Func) bool {\n    t := f.Type()\n    return t.NumIn() == 8 && t.NumOut() == 0\n}","tryCatchPattern":"func safeToFunc8x0(f reflectx.Func) (fn reflectx.Func8x0, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"conversion failed: %v\", r)\n        }\n    }()\n    fn = reflectx.ToFunc8x0(f)\n    return\n}","preventionTips":["Sinks return nothing; use Nx1+ converters if an error return is needed","Verify the 8-parameter signature after adding context/emitter args","Prefer MakeFunc8x0 with a typed function","Run a fast unit test that constructs the sink before launching pipelines"],"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-20T03:17:13.778Z"}