{"record":{"id":"6230a39bf2da1c52","repo":"apache/beam","slug":"unable-to-infer-the-types-of-finishbundle","errorCode":null,"errorMessage":"Unable to infer the types of FinishBundle","messagePattern":"Unable to infer the types of FinishBundle","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/register/register.go","lineNumber":1266,"sourceCode":"\nfunc buildFinishBundleWrapper[I0, I1, I2, I3, I4, I5, I6, I7, I8, I9 any](doFn any) func(any) reflectx.Func {\n\tfinishBundleIn := -1\n\tfinishBundleOut := -1\n\tfinishBundleMethod := reflect.ValueOf(doFn).MethodByName(\"FinishBundle\")\n\tif !finishBundleMethod.IsValid() {\n\t\treturn nil\n\t}\n\tfinishBundleIn = finishBundleMethod.Type().NumIn()\n\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]()","sourceCodeStart":1248,"sourceCodeEnd":1284,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/register/register.go#L1248-L1284","documentation":"In buildFinishBundleWrapper, the finishBundleIn == 0, finishBundleOut == 0 case asserts the DoFn implements finishBundle0x0 (a FinishBundle with no inputs and no outputs). If the assertion fails, the library cannot infer the types for the wrapper and panics. FinishBundle supports only a small set of signatures (optional context/EventTime/BundleFinalization inputs, nothing or error returned).","triggerScenarios":"A DoFn whose FinishBundle takes 0 inputs but is not exactly func() — e.g. it returns a non-error value, or the method name/pointer receiver prevents the finishBundle0x0 interface assertion from succeeding.","commonSituations":"Defining FinishBundle with a value receiver while the assertion is done against the pointer-typed doFn; naming the method Finishbundle; giving FinishBundle an unsupported return type like (bool).","solutions":["Define FinishBundle with a pointer receiver: func (fn *myFn) FinishBundle().","Ensure FinishBundle returns either nothing or exactly one error.","Pass the DoFn pointer (&myFn{}) to register.DoFn so the interface assertion can match.","Rename the method to exactly FinishBundle."],"exampleFix":"// before\nfunc (fn myFn) FinishBundle() bool { ... }\n// after\nfunc (fn *myFn) FinishBundle() { ... }","handlingStrategy":"validation","validationCode":"st := reflect.TypeOf(&myFn{}).Elem()\nif m, ok := st.MethodByName(\"FinishBundle\"); ok {\n    if m.Type.NumIn() != 1 || m.Type.NumOut() != 0 { panic(\"0-input FinishBundle must be func() with no returns\") }\n}\n","typeGuard":"func isBareFinishBundle(fn any) bool { _, ok := fn.(interface{ FinishBundle() }); return ok }\n","tryCatchPattern":"defer func() { if r := recover(); r != nil { err = fmt.Errorf(\"FinishBundle not registerable: %v\", r) } }()\n","preventionTips":["Use pointer receivers on lifecycle methods","Pass &myFn{} to register.DoFn","Name the method exactly FinishBundle","Return nothing or error only"],"tags":["go","beam","dofn","panic","finishbundle"],"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"}