{"record":{"id":"820626396dc43e1a","repo":"apache/beam","slug":"emit-parameters-expected-in-method-v","errorCode":null,"errorMessage":"emit parameters expected in method %v","messagePattern":"emit parameters expected in method (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/fn.go","lineNumber":704,"sourceCode":"\t}\n\treturn nil\n}\n\n// validateEmits compares the emits found in a DoFn method signature with the emits found in\n// the signature for ProcessElement, and performs validation that those match. This function\n// should only be used to validate methods that are expected to have the same emit parameters as\n// ProcessElement.\nfunc validateEmits(processFnEmits []funcx.FnParam, method *funcx.Fn, methodName string) error {\n\tposMethodEmits, numMethodEmits, ok := method.Emits()\n\tnumProcessEmits := len(processFnEmits)\n\n\t// Handle cases where method has no emits.\n\tif !ok {\n\t\tif numProcessEmits == 0 { // We're good, expected no emits.\n\t\t\treturn nil\n\t\t}\n\t\t// Error, missing emits.\n\t\terr := errors.Errorf(\"emit parameters expected in method %v\", methodName)\n\t\treturn errors.SetTopLevelMsgf(err,\n\t\t\t\"Missing emit parameters in the %v method of a DoFn. \"+\n\t\t\t\t\"If emit parameters are present in %v those parameters must also be present in %v.\",\n\t\t\tmethodName, processElementName, methodName)\n\t}\n\n\t// Error if number of emits doesn't match.\n\tif numMethodEmits != numProcessEmits {\n\t\terr := errors.Errorf(\"number of emits in method %v does not match method %v: got %d, expected %d\",\n\t\t\tmethodName, processElementName, numMethodEmits, numProcessEmits)\n\t\treturn errors.SetTopLevelMsgf(err,\n\t\t\t\"Incorrect number of emit parameters in the %v method of a DoFn. \"+\n\t\t\t\t\"The emit parameters should match those of the %v method.\",\n\t\t\tmethodName, processElementName)\n\t}\n\n\t// Error if there's a type mismatch.\n\tmethodEmits := method.Param[posMethodEmits : posMethodEmits+numMethodEmits]","sourceCodeStart":686,"sourceCodeEnd":722,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/fn.go#L686-L722","documentation":"validateEmits checks that if ProcessElement declares emit parameters, every other emitting method (StartBundle, FinishBundle) declares the same ones — and vice versa. When the method has no emits but ProcessElement does, this error fires with a message explaining emits must be consistent across methods.","triggerScenarios":"Declaring ProcessElement(s string, emit func(int)) but StartBundle/FinishBundle without the matching emit func parameter, or declaring a method expected to emit with zero emit parameters while ProcessElement has them.","commonSituations":"Emitting from StartBundle/FinishBundle (e.g. flushing state) but forgetting to add the emit parameter to those methods; refactoring ProcessElement to add an emit without updating StartBundle.","solutions":["Add the same emit func parameter(s) to StartBundle/FinishBundle that ProcessElement declares","Or, if the method should not emit, remove mismatched expectations and keep emission in ProcessElement only","Keep emit signatures identical (type and order) across all emitting methods"],"exampleFix":"// before\nfunc (f *MyFn) StartBundle(ctx context.Context) error { f.emitLater() ... }\nfunc (f *MyFn) ProcessElement(s string, emit func(int)) error { ... }\n// after\nfunc (f *MyFn) StartBundle(ctx context.Context, emit func(int)) error { ... }","handlingStrategy":"validation","validationCode":"// if ProcessElement has emit funcs, StartBundle/FinishBundle must declare identical ones\npe, _ := reflect.TypeOf(fn).MethodByName(\"ProcessElement\")\nsb, hasSb := reflect.TypeOf(fn).MethodByName(\"StartBundle\")\nif hasSb && emitCount(pe.Type) > 0 && emitCount(sb.Type) == 0 {\n  return errors.New(\"StartBundle must declare the same emit parameters as ProcessElement\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep emit func signatures identical across ProcessElement, StartBundle, FinishBundle","Review DoFn signatures after adding or removing emit parameters"],"tags":["go","apache-beam","dofn","emit-functions"],"backgroundTag":"missing-required-argument","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"}