{"record":{"id":"81067257c82d1ce4","repo":"apache/beam","slug":"invalid-signature-for-startbundle","errorCode":null,"errorMessage":"Invalid signature for StartBundle","messagePattern":"Invalid signature for StartBundle","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/register/register.go","lineNumber":251,"sourceCode":"\tstartBundleOut = startBundleMethod.Type().NumOut()\n\tswitch {\n\n\tcase startBundleIn == 0:\n\t\tswitch {\n\t\tcase startBundleOut == 0:\n\t\t\tif _, ok := doFn.(startBundle0x0); ok {\n\t\t\t\treturn registerStartBundle0x0FuncAndMakeStructWrapper()\n\t\t\t} else {\n\t\t\t\tpanic(\"Unable to infer the types of StartBundle\")\n\t\t\t}\n\t\tcase startBundleOut == 1:\n\t\t\tif _, ok := doFn.(startBundle0x1[error]); ok {\n\t\t\t\treturn registerStartBundle0x1FuncAndMakeStructWrapper[error]()\n\t\t\t} else {\n\t\t\t\tpanic(\"Unable to infer the types of StartBundle\")\n\t\t\t}\n\t\tdefault:\n\t\t\tpanic(\"Invalid signature for StartBundle\")\n\t\t}\n\n\tcase startBundleIn == 1:\n\t\tswitch {\n\t\tcase startBundleOut == 0:\n\t\t\tif _, ok := doFn.(startBundle1x0[I9]); ok {\n\t\t\t\treturn registerStartBundle1x0FuncAndMakeStructWrapper[I9]()\n\t\t\t} else if _, ok := doFn.(startBundle1x0[context.Context]); ok {\n\t\t\t\treturn registerStartBundle1x0FuncAndMakeStructWrapper[context.Context]()\n\t\t\t} else if _, ok := doFn.(startBundle1x0[typex.PaneInfo]); ok {\n\t\t\t\treturn registerStartBundle1x0FuncAndMakeStructWrapper[typex.PaneInfo]()\n\t\t\t} else if _, ok := doFn.(startBundle1x0[[]typex.Window]); ok {\n\t\t\t\treturn registerStartBundle1x0FuncAndMakeStructWrapper[[]typex.Window]()\n\t\t\t} else if _, ok := doFn.(startBundle1x0[typex.EventTime]); ok {\n\t\t\t\treturn registerStartBundle1x0FuncAndMakeStructWrapper[typex.EventTime]()\n\t\t\t} else if _, ok := doFn.(startBundle1x0[typex.BundleFinalization]); ok {\n\t\t\t\treturn registerStartBundle1x0FuncAndMakeStructWrapper[typex.BundleFinalization]()\n\t\t\t} else {","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/register/register.go#L233-L269","documentation":"buildStartBundleWrapper counts the StartBundle method's return values via reflection; any method with 0 inputs but more than 1 output falls into the default branch and panics because StartBundle may only return 0 or 1 values (at most an error). The SDK deliberately rejects multi-return StartBundle signatures at registration time.","triggerScenarios":"Registering a DoFn whose StartBundle has 0 input parameters and 2+ return values, e.g. `func (fn myDoFn) StartBundle() (int, error)`, and passing it to beam.ParDo.","commonSituations":"Copy-pasting a ProcessElement-style multi-return signature onto StartBundle; accidentally adding a second return value when adding logging/state; code generators emitting ProcessElement-shaped lifecycle methods.","solutions":["Reduce StartBundle to at most one return value: either no returns or exactly `error`.","Move any non-error outputs into bundle setup done in Setup() or into the DoFn's fields.","Compare against the documented StartBundle signature options in the Beam Go programming guide."],"exampleFix":"// before\nfunc (fn myDoFn) StartBundle() (int, error) { return 0, nil }\n\n// after\nfunc (fn myDoFn) StartBundle() error { return nil }","handlingStrategy":"validation","validationCode":"m := reflect.TypeOf(myDoFn{}).MethodByName(\"StartBundle\")\nif m.IsValid && m.Type.NumOut() > 1 { panic(\"StartBundle must return 0 or 1 values\") }","typeGuard":"func validStartBundleArity(t reflect.Type) bool { m, ok := t.MethodByName(\"StartBundle\"); return !ok || m.Type.NumOut() <= 1 }","tryCatchPattern":"defer func() {\n\tif r := recover(); r != nil {\n\t\tlog.Fatalf(\"invalid StartBundle signature: %v\", r)\n\t}\n}()","preventionTips":["Remember StartBundle returns at most one error","Do not copy ProcessElement multi-return signatures onto lifecycle methods","Add a compile-time interface assertion var _ startBundleShape = myDoFn{}"],"tags":["go","apache-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"}