{"record":{"id":"b7dd3d5fc526d20c","repo":"apache/beam","slug":"mismatched-number-of-named-outputs-received-v-expected-v","errorCode":null,"errorMessage":"mismatched number of named outputs:\nreceived - %v\nexpected - %v","messagePattern":"mismatched number of named outputs:\nreceived - (.+?)\nexpected - (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/xlang.go","lineNumber":135,"sourceCode":"\t\toutputs := t.GetOutputs()\n\t\tfor tag, nodeID := range outputs {\n\t\t\tif pcolID, exists := idxMap[nodeID]; exists {\n\t\t\t\toutputs[tag] = pcolID\n\t\t\t}\n\t\t}\n\t}\n}\n\n// 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","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/xlang.go#L117-L153","documentation":"VerifyNamedOutputs checks that a cross-language transform's expanded outputs match the external transform's expected outputs map. This panic fires when the number of outputs produced by the expanded (remote) transform differs from the number in ext.OutputsMap.","triggerScenarios":"Calling TryCrossLanguage/Expand for an external transform whose expansion response from the expansion service returns a different count of output PCollections than the tags declared by beam.CrossTransform/Output calls.","commonSituations":"Expansion service serving a different version of the transform than the local SDK expects; declaring fewer/more named outputs than the transform actually emits; stale expansion service jar/container.","solutions":["Align the number of beam.CrossTransform outputs with the transform's actual outputs in the expansion service.","Restart/update the expansion service so its transform version matches the client SDK.","Check expansion logs to confirm the expanded transform's output tags and adjust the OutputsMap."],"exampleFix":"// before\nx := xlang.CrossTransform(scope, ext, xlang.UnderlyingMethod(\"v1\"), xlang.Output(\"out\", \"a\"))\n// after\nx := xlang.CrossTransform(scope, ext, xlang.UnderlyingMethod(\"v1\"), xlang.Output(\"out\", \"a\"), xlang.Output(\"out2\", \"b\"))","handlingStrategy":"validation","validationCode":"if got, want := len(expandedOutputs), len(outputsMap); got != want {\n    return fmt.Errorf(\"expansion returned %d outputs, declared %d\", got, want)\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        log.Fatalf(\"cross-language expansion mismatch: %v\", r)\n    }\n}()","preventionTips":["Declare exactly as many outputs as the remote transform emits.","Keep the expansion service and SDK versions in sync.","Inspect expansion service output tags when wiring CrossTransform outputs."],"tags":["go","apache-beam","cross-language","expansion-service"],"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-14T16:17:12.679Z"}