{"record":{"id":"4592a5f3d046e44f","repo":"apache/beam","slug":"failed-to-add-scope-tree-v","errorCode":null,"errorMessage":"failed to add scope tree: %v","messagePattern":"failed to add scope tree: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/translate.go","lineNumber":287,"sourceCode":"\t\tif ok {\n\t\t\treqs = append(reqs, req)\n\t\t}\n\t}\n\tsort.Strings(reqs)\n\treturn reqs\n}\n\nfunc (m *marshaller) addScopeTree(s *ScopeTree) (string, error) {\n\tid := scopeID(s.Scope.Scope)\n\tif _, exists := m.transforms[id]; exists {\n\t\treturn id, nil\n\t}\n\n\tvar subtransforms []string\n\tfor _, edge := range s.Edges {\n\t\tids, err := m.addMultiEdge(edge)\n\t\tif err != nil {\n\t\t\treturn \"\", errors.Wrapf(err, \"failed to add scope tree: %v\", s)\n\t\t}\n\t\tsubtransforms = append(subtransforms, ids...)\n\t}\n\tfor _, tree := range s.Children {\n\t\tid, err := m.addScopeTree(tree)\n\t\tif err != nil {\n\t\t\treturn \"\", errors.Wrapf(err, \"failed to add scope tree: %v\", s)\n\t\t}\n\t\tsubtransforms = append(subtransforms, id)\n\t}\n\n\tmetadata := m.opt.GetContextReg().ExtractTransformMetadata(s.Scope.Scope.Context)\n\n\ttransform := &pipepb.PTransform{\n\t\tUniqueName:    s.Scope.Name,\n\t\tSubtransforms: subtransforms,\n\t\tEnvironmentId: m.addDefaultEnv(),\n\t\tAnnotations:   metadata.Annotations,","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/translate.go#L269-L305","documentation":"addScopeTree failed while converting an edge of a scope into proto transforms: m.addMultiEdge returned an error and it is wrapped with 'failed to add scope tree: %v' naming the scope. This occurs during graphx.Marshal when serializing a Beam pipeline graph to a ModelPipeline proto.","triggerScenarios":"Calling graphx.Marshal (or Marshal/EncodeGraph) on a graph whose scope s contains an edge (s.Edges) that addMultiEdge cannot encode — e.g., invalid input/output kinds, unencodable types, or unregistered external coders within that edge.","commonSituations":"Pipelines using types that fail type-encoding (see decode/encode type errors) at submit time; custom transforms built by hand with malformed edges; SDK version issues with coders.","solutions":["Look at the wrapped inner error to find the actual failing edge/component (often a type or coder encoding failure)","Rebuild the offending transform using the standard beam.* combinators instead of hand-built graph edges","Verify all custom coders are registered before marshaling","Update the Beam SDK to a version where the used types/transforms are fully supported"],"exampleFix":"// before: hand-built edge with wrong input kind\nedge.Input[0].Kind = graph.InputKind(42)\ngraphx.Marshal(m, graph, opts)\n\n// after\nedge.Input[0].Kind = graph.MultiMap\ngraphx.Marshal(m, graph, opts)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if _, err := graphx.Marshal(m, graph, opts); err != nil {\n    if strings.Contains(err.Error(), \"failed to add scope tree\") {\n        return fmt.Errorf(\"pipeline contains an unencodable transform/edge: %w\", err)\n    }\n    return err\n}","preventionTips":["Inspect the full wrapped error chain to find the real failing edge","Register all custom coders/types before marshaling","Avoid hand-built graph edges; use beam.* combinators"],"tags":["beam","go","serialization","graph","marshal"],"backgroundTag":"schema-validation-failed","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"}