apache/beam · error
: failed to find required method on type
Error message
%v: failed to find required %v method on type: %v
What it means
Every CombineFn must define a MergeAccumulators method (or the passed function must be a merge-accumulators-style function). AsCombineFn looks up fn.methods[mergeAccumulatorsName]; when it's absent it fails with this error naming the fn kind (e.g. 'combineFn' or 'funType') and the type name.
Solutions
- Add an exported MergeAccumulators method: `func (fn *MyCombine) MergeAccumulators(a, b MyAccum) MyAccum`.
- Fix method-name spelling/casing to exactly MergeAccumulators.
- If combining with a plain function, use a signature of the form `func(A, A) A` (merge-only).
- Check fn.Name() in the error message to confirm you're validating the intended type.
Example fix
// before: missing method
func (c *Sum) CreateAccumulator() int { return 0 }
func (c *Sum) AddInput(a, i int) int { return a + i }
// after
func (c *Sum) MergeAccumulators(a, b int) int { return a + b } Defensive patterns
Strategy: validation
Validate before calling
if reflect.ValueOf(myCombine).MethodByName("MergeAccumulators").IsZero() {
panic("MyCombine must define exported MergeAccumulators")
} Type guard
func hasMergeAccumulators(v interface{}) bool {
return !reflect.ValueOf(v).MethodByName("MergeAccumulators").IsZero()
} Prevention
- Always define MergeAccumulators first when writing a CombineFn.
- Keep method names exactly exported: MergeAccumulators, CreateAccumulator, AddInput, ExtractOutput.
When it happens
Trigger: Passing a struct to beam.Combine that defines CreateAccumulator/AddInput/ExtractOutput but no exported MergeAccumulators method.
Common situations: Misspelling the method (MergeAccumulator, MergeAccumulatorsFn); defining it unexported (mergeAccumulators); implementing only some methods when migrating from a plain func to a CombineFn struct.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- bad combinefn
- invalid CombineFn
- MergeAccumulators must be defined on accumulator
- : requires at least 1 return value.
- bad coder kind
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/798d508fe614e8ad.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/core/graph/fn.go:1527
if err != nil {
return nil, errors.WithContext(errors.Wrapf(err, "invalid CombineFn"), "constructing CombineFn")
}
return AsCombineFn(ret)
}
// AsCombineFn converts a Fn to a CombineFn, if possible.
func AsCombineFn(fn *Fn) (*CombineFn, error) {
const fnKind = "graph.AsCombineFn"
if fn.methods == nil {
fn.methods = make(map[string]*funcx.Fn)
}
if fn.Fn != nil {
fn.methods[mergeAccumulatorsName] = fn.Fn
}
mergeFn, ok := fn.methods[mergeAccumulatorsName]
if !ok {
return nil, errors.Errorf("%v: failed to find required %v method on type: %v", fnKind, mergeAccumulatorsName, fn.Name())
}
// CombineFn methods must satisfy the following:
// CreateAccumulator func() (A, error?)
// AddInput func(A, I) (A, error?)
// MergeAccumulators func(A, A) (A, error?)
// ExtractOutput func(A) (O, error?)
// This means that the other signatures *must* match the type used in MergeAccumulators.
if len(mergeFn.Ret) <= 0 {
return nil, errors.Errorf("%v: %v requires at least 1 return value. : %v", fnKind, mergeAccumulatorsName, mergeFn)
}
accumType := mergeFn.Ret[0].T
for _, mthd := range []struct {
name string
sigFunc func(fx *funcx.Fn, accumType reflect.Type) *funcx.Signature
}{
{mergeAccumulatorsName, func(fx *funcx.Fn, accumType reflect.Type) *funcx.Signature {View on GitHub (pinned to 12126d8942)