{"record":{"id":"e5c84e3cc38a577d","repo":"apache/beam","slug":"may-only-have-a-single-bundlefinalization-parameter-and-it","errorCode":null,"errorMessage":"may only have a single BundleFinalization parameter and it must precede the main input parameter","messagePattern":"may only have a single BundleFinalization parameter and it must precede the main input parameter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/funcx/fn.go","lineNumber":536,"sourceCode":"\t// Validate the return value ordering.\n\tretState := rsStart\n\tfor i, r := range u.Ret {\n\t\tif retState, err = nextRetState(retState, r.Kind); err != nil {\n\t\t\treturn errors.WithContextf(err, \"validating return value %d for %s\", i, u.Fn.Name())\n\t\t}\n\t}\n\treturn nil\n}\n\nvar (\n\terrContextParam                      = errors.New(\"may only have a single context.Context parameter and it must be the first parameter\")\n\terrPaneParamPrecedence               = errors.New(\"may only have a single PaneInfo parameter and it must precede the WindowParam, EventTime and main input parameter\")\n\terrWindowParamPrecedence             = errors.New(\"may only have a single Window parameter and it must precede the EventTime and main input parameter\")\n\terrEventTimeParamPrecedence          = errors.New(\"may only have a single beam.EventTime parameter and it must precede the main input parameter\")\n\terrWatermarkEstimatorParamPrecedence = errors.New(\"may only have a single sdf.WatermarkEstimator parameter and it must precede the main input parameter\")\n\terrReflectTypePrecedence             = errors.New(\"may only have a single reflect.Type parameter and it must precede the main input parameter\")\n\terrRTrackerPrecedence                = errors.New(\"may only have a single sdf.RTracker parameter and it must precede the main input parameter\")\n\terrBundleFinalizationPrecedence      = errors.New(\"may only have a single BundleFinalization parameter and it must precede the main input parameter\")\n\terrStateProviderPrecedence           = errors.New(\"may only have a single state.Provider parameter and it must precede the main input parameter\")\n\terrTimerProviderPrecedence           = errors.New(\"may only have a single timer.Provider parameter and it must precede the main input parameter\")\n\terrInputPrecedence                   = errors.New(\"inputs parameters must precede emit function parameters\")\n)\n\ntype paramState int\n\nconst (\n\tpsStart paramState = iota\n\tpsContext\n\tpsPane\n\tpsWindow\n\tpsEventTime\n\tpsWatermarkEstimator\n\tpsType\n\tpsInput\n\tpsOutput\n\tpsRTracker","sourceCodeStart":518,"sourceCodeEnd":554,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/funcx/fn.go#L518-L554","documentation":"Sentinel error errBundleFinalizationPrecedence from the funcx parameter state machine: a typex.BundleFinalization parameter appeared after the main input parameter (as in the fn_test case where it follows the element and reflect.Type), or more than one was declared. Bundle finalization callbacks must be a single parameter preceding the main input.","triggerScenarios":"Thrown at sdks/go/pkg/beam/core/funcx/fn.go:536 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reorder so typex.BundleFinalization comes before the main input parameter","Keep exactly one BundleFinalization parameter"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}