{"record":{"id":"f496ee9d9c578201","repo":"apache/beam","slug":"panic-formatpardoerror-dofn-len-ret-6","errorCode":null,"errorMessage":"panic(formatParDoError(dofn, len(ret), 6))","messagePattern":"panic\\(formatParDoError\\(dofn, len\\(ret\\), 6\\)\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/pardo.go","lineNumber":478,"sourceCode":"\t\tpanic(formatParDoError(dofn, len(ret), 4))\n\t}\n\treturn ret[0], ret[1], ret[2], ret[3]\n}\n\n// ParDo5 inserts a ParDo with 5 outputs into the pipeline.\nfunc ParDo5(s Scope, dofn any, col PCollection, opts ...Option) (PCollection, PCollection, PCollection, PCollection, PCollection) {\n\tret := MustN(TryParDo(s, dofn, col, opts...))\n\tif len(ret) != 5 {\n\t\tpanic(formatParDoError(dofn, len(ret), 5))\n\t}\n\treturn ret[0], ret[1], ret[2], ret[3], ret[4]\n}\n\n// ParDo6 inserts a ParDo with 6 outputs into the pipeline.\nfunc ParDo6(s Scope, dofn any, col PCollection, opts ...Option) (PCollection, PCollection, PCollection, PCollection, PCollection, PCollection) {\n\tret := MustN(TryParDo(s, dofn, col, opts...))\n\tif len(ret) != 6 {\n\t\tpanic(formatParDoError(dofn, len(ret), 6))\n\t}\n\treturn ret[0], ret[1], ret[2], ret[3], ret[4], ret[5]\n}\n\n// ParDo7 inserts a ParDo with 7 outputs into the pipeline.\nfunc ParDo7(s Scope, dofn any, col PCollection, opts ...Option) (PCollection, PCollection, PCollection, PCollection, PCollection, PCollection, PCollection) {\n\tret := MustN(TryParDo(s, dofn, col, opts...))\n\tif len(ret) != 7 {\n\t\tpanic(formatParDoError(dofn, len(ret), 7))\n\t}\n\treturn ret[0], ret[1], ret[2], ret[3], ret[4], ret[5], ret[6]\n}\n\n// formatParDoError is a helper function to provide a more concise error\n// message to the users when a DoFn and its ParDo pairing is incorrect.\n//\n// We construct a new graph.Fn using the doFn which is passed. We explicitly\n// ignore the error since we already know that its already a DoFn type as","sourceCodeStart":460,"sourceCodeEnd":496,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/pardo.go#L460-L496","documentation":"Panic raised by ParDo6 when MustN(TryParDo(...)) yields a slice whose length is not exactly 6. The DoFn's output arity (number of emitted outputs / output tags) disagrees with the 6 outputs this fixed-arity helper unpacks, so the tuple unpack cannot proceed; the message via formatParDoError states expected vs actual counts.","triggerScenarios":"Calling beam.ParDo6 with a DoFn whose ProcessElement does not emit exactly 6 outputs.","commonSituations":"Large fan-out DoFns are error-prone; typically a DoFn with 5 or 7 emits is passed, or emit struct fields were reordered/removed during refactoring.","solutions":["Align the DoFn's ProcessElement to emit exactly 6 outputs.","Or use the ParDoN variant matching the actual output count.","Switch to TryParDo/ParDoN when output count is computed at runtime."],"exampleFix":"// before: DoFn has only 6 emit fields but one is unused/not counted\n// after: ensure exactly 6 emit funcs are declared and used in ProcessElement\nbeam.ParDo6(s, &fn{}, col)","handlingStrategy":"validation","validationCode":"if outputsOfMyDoFn != 6 { log.Fatalf(\"expected 6 outputs, got %d\", outputsOfMyDoFn) }","typeGuard":null,"tryCatchPattern":"defer func() { if r := recover(); r != nil { err = fmt.Errorf(\"ParDo6 failed: %v\", r) } }()","preventionTips":["For high fan-out DoFns, name emit fields clearly to avoid miscounting","Use TryParDo when the output count is data-dependent","Keep one DoFn definition per ParDoN call site"],"tags":["go","apache-beam","pardo","panic","signature-mismatch"],"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"}