{"record":{"id":"8262a8f16b1805a3","repo":"apache/beam","slug":"invalid-signature-for-finishbundle","errorCode":null,"errorMessage":"Invalid signature for FinishBundle","messagePattern":"Invalid signature for FinishBundle","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/register/register.go","lineNumber":1275,"sourceCode":"\tfinishBundleOut = finishBundleMethod.Type().NumOut()\n\tswitch {\n\n\tcase finishBundleIn == 0:\n\t\tswitch {\n\t\tcase finishBundleOut == 0:\n\t\t\tif _, ok := doFn.(finishBundle0x0); ok {\n\t\t\t\treturn registerFinishBundle0x0FuncAndMakeStructWrapper()\n\t\t\t} else {\n\t\t\t\tpanic(\"Unable to infer the types of FinishBundle\")\n\t\t\t}\n\t\tcase finishBundleOut == 1:\n\t\t\tif _, ok := doFn.(finishBundle0x1[error]); ok {\n\t\t\t\treturn registerFinishBundle0x1FuncAndMakeStructWrapper[error]()\n\t\t\t} else {\n\t\t\t\tpanic(\"Unable to infer the types of FinishBundle\")\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"Invalid signature for FinishBundle\")\n\t\t}\n\n\tcase finishBundleIn == 1:\n\t\tswitch {\n\t\tcase finishBundleOut == 0:\n\t\t\tif _, ok := doFn.(finishBundle1x0[I9]); ok {\n\t\t\t\treturn registerFinishBundle1x0FuncAndMakeStructWrapper[I9]()\n\t\t\t} else if _, ok := doFn.(finishBundle1x0[context.Context]); ok {\n\t\t\t\treturn registerFinishBundle1x0FuncAndMakeStructWrapper[context.Context]()\n\t\t\t} else if _, ok := doFn.(finishBundle1x0[typex.PaneInfo]); ok {\n\t\t\t\treturn registerFinishBundle1x0FuncAndMakeStructWrapper[typex.PaneInfo]()\n\t\t\t} else if _, ok := doFn.(finishBundle1x0[[]typex.Window]); ok {\n\t\t\t\treturn registerFinishBundle1x0FuncAndMakeStructWrapper[[]typex.Window]()\n\t\t\t} else if _, ok := doFn.(finishBundle1x0[typex.EventTime]); ok {\n\t\t\t\treturn registerFinishBundle1x0FuncAndMakeStructWrapper[typex.EventTime]()\n\t\t\t} else if _, ok := doFn.(finishBundle1x0[typex.BundleFinalization]); ok {\n\t\t\t\treturn registerFinishBundle1x0FuncAndMakeStructWrapper[typex.BundleFinalization]()\n\t\t\t} else {","sourceCodeStart":1257,"sourceCodeEnd":1293,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/register/register.go#L1257-L1293","documentation":"This panic is the inner default of buildFinishBundleWrapper for the 0-input case: the FinishBundle output count was neither 0 nor 1. Beam only permits FinishBundle to return nothing or a single error, so any other number of return values is an invalid signature and registration aborts.","triggerScenarios":"A FinishBundle method with no inputs returning two or more values (e.g. (int, error)) or three values, then the DoFn is registered via register.DoFn/used in a pipeline.","commonSituations":"Copying ProcessElement's multi-return style onto FinishBundle; adding a debug return value to FinishBundle during development and forgetting to remove it.","solutions":["Change FinishBundle to return nothing or exactly one error value.","Log diagnostics instead of returning extra values from FinishBundle.","Move metrics/extra outputs to ProcessElement or bundle finalization callbacks (BundleFinalization).","Re-run registration after fixing; the panic occurs at pipeline construction time, not runtime execution."],"exampleFix":"// before\nfunc (fn *myFn) FinishBundle() (int, error) { ... }\n// after\nfunc (fn *myFn) FinishBundle() error { ... }","handlingStrategy":"validation","validationCode":"t := reflect.TypeOf(&myFn{}).Elem().MethodByName(\"FinishBundle\").Type\nif t.NumOut() > 1 { panic(\"FinishBundle may return at most one error\") }\n","typeGuard":"func atMostOneReturn(t reflect.Type) bool { return t.NumOut() <= 1 }\n","tryCatchPattern":"defer func() { if r := recover(); r != nil { err = fmt.Errorf(\"FinishBundle arity invalid: %v\", r) } }()\n","preventionTips":["FinishBundle returns zero values or a single error","Log instead of returning diagnostics","Review signatures when copying from other DoFn methods"],"tags":["go","beam","dofn","signature","panic"],"backgroundTag":"unsupported-operation","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"}