{"record":{"id":"876696861fa1143d","repo":"apache/beam","slug":"invalid-combinefn","errorCode":null,"errorMessage":"invalid CombineFn","messagePattern":"invalid CombineFn","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/fn.go","lineNumber":1510,"sourceCode":"func (f *CombineFn) CompactFn() *funcx.Fn {\n\treturn f.methods[compactName]\n}\n\n// TeardownFn returns the \"Teardown\" function, if present.\nfunc (f *CombineFn) TeardownFn() *funcx.Fn {\n\treturn f.methods[teardownName]\n}\n\n// Name returns the name of the function or struct.\nfunc (f *CombineFn) Name() string {\n\treturn (*Fn)(f).Name()\n}\n\n// NewCombineFn constructs a CombineFn from the given value, if possible.\nfunc NewCombineFn(fn any) (*CombineFn, error) {\n\tret, err := NewFn(fn)\n\tif err != nil {\n\t\treturn nil, errors.WithContext(errors.Wrapf(err, \"invalid CombineFn\"), \"constructing CombineFn\")\n\t}\n\treturn AsCombineFn(ret)\n}\n\n// AsCombineFn converts a Fn to a CombineFn, if possible.\nfunc AsCombineFn(fn *Fn) (*CombineFn, error) {\n\tconst fnKind = \"graph.AsCombineFn\"\n\tif fn.methods == nil {\n\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}","sourceCodeStart":1492,"sourceCodeEnd":1528,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/fn.go#L1492-L1528","documentation":"NewCombineFn wraps NewFn and AsCombineFn; if the supplied value is not a valid CombineFn (wrong kind of function/struct or methods missing), the underlying error is wrapped with context 'constructing CombineFn' and surfaced as 'invalid CombineFn'. Beam only accepts structs implementing the CombineFn method set (CreateAccumulator/AddInput/MergeAccumulators/ExtractOutput) or MergeAccumulators-only functions.","triggerScenarios":"Calling beam.Combine/Add(beam.CombinePerKey, someValue) with a value that is neither a valid combine struct nor a function, or one whose CombineFn methods have wrong signatures.","commonSituations":"Passing a plain function that isn't a merge-accumulators-only signature; passing a struct that's missing MergeAccumulators; typos in method names (lowercase unexported methods); passing a value of a non-func type entirely.","solutions":["Inspect the wrapped inner error via errors.Context for the exact reason NewFn failed.","Ensure the value is either a struct with the CombineFn method set or a func with MergeAccumulators-compatible signature.","Export the CombineFn methods (MergeAccumulators, CreateAccumulator, AddInput, ExtractOutput).","Verify accumulator type is consistent across all CombineFn methods."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify at init that the combine value implements the required method set\nvar _ = func() error {\n    if _, err := graph.NewCombineFn(MyCombine{}); err != nil { return err }\n    return nil\n}","typeGuard":"func isCombineFn(v interface{}) bool {\n    m := reflect.ValueOf(v)\n    return m.MethodByName(\"MergeAccumulators\").IsValid()\n}","tryCatchPattern":null,"preventionTips":["Embed the CombineFn method set early with a compile-time interface assertion where possible.","Keep accumulator types identical across all four methods."],"tags":["beam","go","combinefn","graph-validation"],"backgroundTag":"invalid-argument-value","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"}