{"record":{"id":"fb563d78680abc1d","repo":"apache/beam","slug":"v-v-requires-at-least-1-return-value-v","errorCode":null,"errorMessage":"%v: %v requires at least 1 return value. : %v","messagePattern":"(.+?): (.+?) requires at least 1 return value\\. : (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/fn.go","lineNumber":1537,"sourceCode":"\t\tfn.methods = make(map[string]*funcx.Fn)\n\t}\n\tif fn.Fn != nil {\n\t\tfn.methods[mergeAccumulatorsName] = fn.Fn\n\t}\n\n\tmergeFn, ok := fn.methods[mergeAccumulatorsName]\n\tif !ok {\n\t\treturn nil, errors.Errorf(\"%v: failed to find required %v method on type: %v\", fnKind, mergeAccumulatorsName, fn.Name())\n\t}\n\n\t// CombineFn methods must satisfy the following:\n\t// CreateAccumulator func() (A, error?)\n\t// AddInput func(A, I) (A, error?)\n\t// MergeAccumulators func(A, A) (A, error?)\n\t// ExtractOutput func(A) (O, error?)\n\t// This means that the other signatures *must* match the type used in MergeAccumulators.\n\tif len(mergeFn.Ret) <= 0 {\n\t\treturn nil, errors.Errorf(\"%v: %v requires at least 1 return value. : %v\", fnKind, mergeAccumulatorsName, mergeFn)\n\t}\n\taccumType := mergeFn.Ret[0].T\n\n\tfor _, mthd := range []struct {\n\t\tname    string\n\t\tsigFunc func(fx *funcx.Fn, accumType reflect.Type) *funcx.Signature\n\t}{\n\t\t{mergeAccumulatorsName, func(fx *funcx.Fn, accumType reflect.Type) *funcx.Signature {\n\t\t\treturn funcx.Replace(mergeAccumulatorsSig, typex.TType, accumType)\n\t\t}},\n\t\t{createAccumulatorName, func(fx *funcx.Fn, accumType reflect.Type) *funcx.Signature {\n\t\t\treturn funcx.Replace(createAccumulatorSig, typex.TType, accumType)\n\t\t}},\n\t\t{addInputName, func(fx *funcx.Fn, accumType reflect.Type) *funcx.Signature {\n\t\t\t// AddInput needs the last parameter type substituted.\n\t\t\tp := fx.Param[len(fx.Param)-1]\n\t\t\taiSig := funcx.Replace(addInputSig, typex.TType, accumType)\n\t\t\treturn funcx.Replace(aiSig, typex.VType, p.T)","sourceCodeStart":1519,"sourceCodeEnd":1555,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/fn.go#L1519-L1555","documentation":"MergeAccumulators must return the accumulator type; its first return value defines the accumulator type A that all other CombineFn methods must match. If the method returns no values, fn.go cannot determine the accumulator type and rejects the CombineFn with this error.","triggerScenarios":"Defining MergeAccumulators with zero return values, e.g. `func (c *C) MergeAccumulators(a, b Acc)` (mutating in place) or `func(a, b int) {}`.","commonSituations":"Writing a merge method that mutates an accumulator pointer and returns nothing; copying patterns from other frameworks where merges are in-place; accidentally returning nothing after refactoring.","solutions":["Change MergeAccumulators to return at least one value of the accumulator type, e.g. `func (c *C) MergeAccumulators(a, b Acc) Acc`.","Make sure all other methods (CreateAccumulator, AddInput, ExtractOutput) use that same accumulator type.","Remove error return confusion — errors are optional extra returns, but the accumulator must be first."],"exampleFix":"// before\nfunc (c *Sum) MergeAccumulators(a, b int) { c.total = a + b }\n// after\nfunc (c *Sum) MergeAccumulators(a, b int) int { return a + b }","handlingStrategy":"validation","validationCode":"// static check at init\nvar _ = func() {\n    mt := reflect.TypeOf((*Sum)(nil)).MethodByName(\"MergeAccumulators\")\n    if mt.Type.NumOut() == 0 { panic(\"MergeAccumulators must return the accumulator\") }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["MergeAccumulators must return (A) or (A, error) — never zero returns.","Avoid in-place mutation patterns; return the merged accumulator."],"tags":["beam","go","combinefn","signature-validation"],"backgroundTag":"invalid-argument-format","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"}