{"record":{"id":"e375b4eea26f0055","repo":"apache/beam","slug":"panic-formatpardoerror-dofn-len-ret-7","errorCode":null,"errorMessage":"panic(formatParDoError(dofn, len(ret), 7))","messagePattern":"panic\\(formatParDoError\\(dofn, len\\(ret\\), 7\\)\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/pardo.go","lineNumber":487,"sourceCode":"\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\n// TryParDo would have panicked otherwise.\nfunc formatParDoError(doFn any, emitSize int, parDoSize int) string {\n\tdoFun, _ := graph.NewFn(doFn)\n\tdoFnName := doFun.Name()\n\n\tthisParDo := parDoForSize(parDoSize) // Conveniently keeps the API slim.\n\tcorrectParDo := parDoForSize(emitSize)\n\n\treturn fmt.Sprintf(\"DoFn %v has %v outputs, but %v requires %v outputs, use %v instead.\", doFnName, emitSize, thisParDo, parDoSize, correctParDo)","sourceCodeStart":469,"sourceCodeEnd":505,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/pardo.go#L469-L505","documentation":"Panic raised by ParDo7 when TryParDo returns a count of output PCollections different from 7. As with the other fixed-arity ParDoN wrappers, this is a construction-time arity mismatch between what the DoFn actually emits and the number of return values the caller expects to unpack.","triggerScenarios":"Calling beam.ParDo7 with a DoFn whose ProcessElement does not emit exactly 7 outputs.","commonSituations":"Rarely used high-fan-out variant; usually hit when a team generalizes an existing multi-output DoFn or miscounts emit parameters in a large ProcessElement signature.","solutions":["Make ProcessElement emit exactly 7 outputs (7 emit fields or 7 return values).","Or pick the ParDoN helper matching the DoFn's actual count.","For dynamic counts, use TryParDo and handle the error instead of panicking."],"exampleFix":"// before: 7 emit tags declared, only 6 wired into ProcessElement\n// after: wire all 7 emitters in ProcessElement\nbeam.ParDo7(s, &fn{}, col)","handlingStrategy":"validation","validationCode":"if outputsOfMyDoFn != 7 { log.Fatalf(\"expected 7 outputs, got %d\", outputsOfMyDoFn) }","typeGuard":null,"tryCatchPattern":"defer func() { if r := recover(); r != nil { err = fmt.Errorf(\"ParDo7 failed: %v\", r) } }()","preventionTips":["Wire every emit field into ProcessElement; unused emits change the arity","Test pipeline construction in unit tests to fail fast","Consider restructuring with fewer output tags if arity keeps drifting"],"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"}