{"record":{"id":"7ce8d794c6f382cc","repo":"apache/beam","slug":"error-must-be-the-final-return-parameter","errorCode":null,"errorMessage":"error must be the final return parameter","messagePattern":"error must be the final return parameter","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/funcx/fn.go","lineNumber":748,"sourceCode":"\t\treturn -1, errBundleFinalizationPrecedence\n\tcase FnRTracker:\n\t\treturn -1, errRTrackerPrecedence\n\tcase FnStateProvider:\n\t\treturn -1, errStateProviderPrecedence\n\tcase FnTimerProvider:\n\t\treturn -1, errTimerProviderPrecedence\n\tcase FnIter, FnReIter, FnValue, FnMultiMap:\n\t\treturn psInput, nil\n\tcase FnEmit:\n\t\treturn psOutput, nil\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"library error, unknown ParamKind: %v\", transition))\n\t}\n}\n\nvar (\n\terrEventTimeRetPrecedence        = errors.New(\"beam.EventTime must be first return parameter\")\n\terrErrorPrecedence               = errors.New(\"error must be the final return parameter\")\n\terrProcessContinuationPrecedence = errors.New(\"ProcessContinuation must be the final non-error return parameter\")\n)\n\ntype retState int\n\nconst (\n\trsStart retState = iota\n\trsEventTime\n\trsOutput\n\trsError\n\trsProcessContinuation\n)\n\nfunc nextRetState(cur retState, transition ReturnKind) (retState, error) {\n\tswitch cur {\n\tcase rsStart:\n\t\tswitch transition {\n\t\tcase RetEventTime:","sourceCodeStart":730,"sourceCodeEnd":766,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/funcx/fn.go#L730-L766","documentation":"Sentinel error errErrorPrecedence from the funcx return-value state machine: once an error return is seen the machine enters the terminal rsError state, so any subsequent return parameter is invalid. If a DoFn method returns an error, it must be the final return value.","triggerScenarios":"Thrown at sdks/go/pkg/beam/core/funcx/fn.go:748 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the error return to the last position of the return signature","Remove any return values declared after the error"],"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"}