{"record":{"id":"535d6d88db5a42b5","repo":"apache/beam","slug":"mismatched-number-of-unnamed-outputs-received-v-expected-1","errorCode":null,"errorMessage":"mismatched number of unnamed outputs:\nreceived - %v\nexpected - 1","messagePattern":"mismatched number of unnamed outputs:\nreceived - (.+?)\nexpected - 1","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/xlang.go","lineNumber":144,"sourceCode":"// VerifyNamedOutputs ensures the expanded outputs correspond to the correct and expected named outputs\nfunc VerifyNamedOutputs(ext *graph.ExternalTransform) {\n\ttransform, err := ExpandedTransform(ext.Expanded)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\texpandedOutputs := transform.GetOutputs()\n\n\tif len(expandedOutputs) != len(ext.OutputsMap) {\n\t\tpanic(errors.Errorf(\"mismatched number of named outputs:\\nreceived - %v\\nexpected - %v\", len(expandedOutputs), len(ext.OutputsMap)))\n\t}\n\n\tfor tag := range ext.OutputsMap {\n\t\t_, exists := expandedOutputs[tag]\n\t\tif tag != graph.UnnamedOutputTag && !exists {\n\t\t\tpanic(errors.Errorf(\"missing named output in expanded transform: %v is expected in %v\", tag, expandedOutputs))\n\t\t}\n\t\tif tag == graph.UnnamedOutputTag && len(expandedOutputs) > 1 {\n\t\t\tpanic(errors.Errorf(\"mismatched number of unnamed outputs:\\nreceived - %v\\nexpected - 1\", len(expandedOutputs)))\n\t\t}\n\t}\n}\n\n// ResolveOutputIsBounded updates each Output node with respect to the received\n// expanded components to reflect if it is bounded or not\nfunc ResolveOutputIsBounded(e *graph.MultiEdge, isBoundedUpdater func(*graph.Node, bool)) {\n\text := e.External\n\texp := ext.Expanded\n\tcomponents, err := ExpandedComponents(exp)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\texpandedPCollections := components.GetPcollections()\n\ttransform, err := ExpandedTransform(exp)\n\tif err != nil {\n\t\tpanic(err)\n\t}","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/xlang.go#L126-L162","documentation":"When a cross-language transform is declared with the unnamed output tag, the expanded transform is expected to produce exactly one output. This panic fires when the unnamed tag is used but the expansion returned multiple outputs.","triggerScenarios":"Expanding an external transform with a single unnamed output declared while the expansion service response contains more than one output PCollection.","commonSituations":"Using the default/unnamed output mapping with a multi-output transform; SDK version where a previously single-output transform gained extra outputs.","solutions":["Declare each expanded output explicitly with named tags instead of a single unnamed output.","Use an expansion-service transform version that matches the expected single-output shape.","Inspect the expansion response and pick the correct output tag before wiring consumers."],"exampleFix":"// before\nx := xlang.CrossTransform(scope, ext) // implicit single unnamed output\n// after\nx := xlang.CrossTransform(scope, ext, xlang.Output(\"main\", \"a\"), xlang.Output(\"side\", \"b\"))","handlingStrategy":"validation","validationCode":"if usesUnnamedOutput && len(expandedOutputs) > 1 {\n    return fmt.Errorf(\"multi-output transform requires named tags, got %d outputs\", len(expandedOutputs))\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        log.Fatalf(\"unnamed output used with multi-output transform: %v\", r)\n    }\n}()","preventionTips":["Always use explicit named outputs for transforms known to emit multiple PCollections.","Re-check output shape after upgrading the expansion service.","Document per-transform output arity in pipeline code."],"tags":["go","apache-beam","cross-language","named-outputs"],"backgroundTag":"unexpected-response-shape","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"}