{"record":{"id":"46b65c27cf1ac620","repo":"apache/beam","slug":"gbk-cogbk-result-values-must-be-iterable-v","errorCode":null,"errorMessage":"GBK/CoGBK result values must be iterable: %v","messagePattern":"GBK/CoGBK result values must be iterable: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/exec/fn.go","lineNumber":275,"sourceCode":"\t\t\tfrom := reflect.TypeOf(opts.opt.Key.Elm)\n\t\t\tn.elmConvert = ConvertFn(from, fn.Param[in[i]].T)\n\t\t}\n\t\targs[in[i]] = n.elmConvert(opts.opt.Key.Elm)\n\t\ti++\n\t\tif opts.opt.Key.Elm2 != nil {\n\t\t\tif n.elm2Convert == nil {\n\t\t\t\tfrom := reflect.TypeOf(opts.opt.Key.Elm2)\n\t\t\t\tn.elm2Convert = ConvertFn(from, fn.Param[in[i]].T)\n\t\t\t}\n\t\t\targs[in[i]] = n.elm2Convert(opts.opt.Key.Elm2)\n\t\t\ti++\n\t\t}\n\n\t\tfor _, iter := range opts.opt.Values {\n\t\t\tparam := fn.Param[in[i]]\n\n\t\t\tif param.Kind != funcx.FnIter {\n\t\t\t\treturn nil, errors.Errorf(\"GBK/CoGBK result values must be iterable: %v\", param)\n\t\t\t}\n\n\t\t\t// TODO(herohde) 12/12/2017: allow form conversion on GBK results?\n\n\t\t\tit := makeIter(param.T, iter)\n\t\t\tit.Init()\n\t\t\targs[in[i]] = it.Value()\n\t\t\t// Ensure main value iterators are reset & closed after the invoke to avoid\n\t\t\t// short read problems.\n\t\t\tdefer it.Reset()\n\t\t\ti++\n\t\t}\n\t}\n\n\t// (3) Precomputed side input and emitters (or other output).\n\tfor _, arg := range opts.extra {\n\t\targs[in[i]] = arg\n\t\ti++","sourceCodeStart":257,"sourceCodeEnd":293,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/fn.go#L257-L293","documentation":"When a DoFn receives GBK/CoGBK results, each value parameter must be an iterator function (func(*T) bool) matching funcx.FnIter. If the declared parameter kind is not an iterator, invokeWithOpts returns this error with the offending param. The Go DoFn signature does not match the shape required to consume the grouped values.","triggerScenarios":"A ProcessElement handling GBK output declares the values parameter as a slice, concrete type, or function that is not `func(*V) bool`; opts.opt.Values contains iterables but param.Kind != funcx.FnIter.","commonSituations":"Migrating from Python/Java Beam where GBK results arrive as lists; writing ProcessElement(k string, vs []V) instead of an iterator function; misuse of beam.CoGBK outputs in Go.","solutions":["Change the values parameter to an iterator function signature: func(vs func(*V) bool) or func(k string, vs func(*V) bool)","Check beam.reflect.MakeFunc4/invoke docs for accepted ProcessElement signatures","Use beam.TryGrouped/CoGBK examples from the SDK as reference","Recompile and inspect fn.Param diagnostics for the DoFn"],"exampleFix":"// before\nfunc (fn *myFn) ProcessElement(k string, vs []V) {\n    for _, v := range vs { ... } // not iterable param kind\n}\n// after\nfunc (fn *myFn) ProcessElement(k string, vs func(*V) bool) {\n    var v V\n    for vs(&v) { ... }\n}","handlingStrategy":"validation","validationCode":"// check DoFn param shape before registering\n// values param for GBK must be func(*V) bool\nfunc isIterParam(fn interface{}) bool {\n    t := reflect.TypeOf(fn)\n    return t.Kind() == reflect.Func && t.NumIn() == 1 &&\n        t.In(0).Kind() == reflect.Ptr && t.Out(0).Kind() == reflect.Bool\n}","typeGuard":null,"tryCatchPattern":"// DoFn signature errors are caught at plan-build/invoke time\nif err != nil && strings.Contains(err.Error(), \"must be iterable\") {\n    return fmt.Errorf(\"fix ProcessElement signature: values param must be func(*V) bool: %w\", err)\n}","preventionTips":["Always accept GBK values as an iterator function (func(*V) bool)","Copy signatures from official Beam Go GBK/CoGBK examples","Compile-check DoFn signatures with beam.Try* helpers before deploy","Don't translate list-style GBK idioms from Python/Java into Go"],"tags":["beam","go","gbk","dofn","signature"],"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-14T16:17:12.679Z"}