{"record":{"id":"6d34c3e4b9e9a4d4","repo":"apache/beam","slug":"invalid-pcollection-to-external-index-v","errorCode":null,"errorMessage":"invalid pcollection to external: index %v","messagePattern":"invalid pcollection to external: index (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/external.go","lineNumber":44,"sourceCode":"// URN provided to implement the behavior of the operation. Transform\n// libraries should expose an API that captures the user's intent and serialize\n// the payload as a byte slice that the runner will deserialize.\n//\n// Use ExternalTagged if the runner will need to associate the PTransforms local PCollection tags\n// with values in the payload.\nfunc External(s Scope, urn string, payload []byte, in []PCollection, out []FullType, bounded bool) []PCollection {\n\treturn MustN(TryExternal(s, urn, payload, in, out, bounded))\n}\n\n// TryExternal attempts to perform the work of External, returning an error indicating\n// why the operation failed.\nfunc TryExternal(s Scope, urn string, payload []byte, in []PCollection, out []FullType, bounded bool) ([]PCollection, error) {\n\tif !s.IsValid() {\n\t\treturn nil, errors.New(\"invalid scope\")\n\t}\n\tfor i, col := range in {\n\t\tif !col.IsValid() {\n\t\t\treturn nil, errors.Errorf(\"invalid pcollection to external: index %v\", i)\n\t\t}\n\t}\n\n\tvar ins []*graph.Node\n\tfor _, col := range in {\n\t\tins = append(ins, col.n)\n\t}\n\tedge := graph.NewExternal(s.real, s.scope, &graph.Payload{URN: urn, Data: payload}, ins, out, bounded)\n\n\tvar ret []PCollection\n\tfor _, out := range edge.Output {\n\t\tc := PCollection{out.To}\n\t\tc.SetCoder(NewCoder(c.Type()))\n\t\tret = append(ret, c)\n\t}\n\treturn ret, nil\n}\n","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/external.go#L26-L62","documentation":"TryExternal validates every input PCollection passed to an external transform (beam.External/TryExternal in sdks/go/pkg/beam/external.go). If any input PCollection is invalid (zero value, not produced by a valid scope, e.g. the PCollection{} zero value), it fails with this message including the offending index. It guards against wiring uninitialized collections into an external transform.","triggerScenarios":"Passing a zero-value beam.PCollection{} or a PCollection created outside a valid scope into beam.External's in []PCollection parameter.","commonSituations":"Declaring `var in beam.PCollection` and forgetting to assign it from a prior transform; constructing PCollections manually instead of via pipeline combinators.","solutions":["Check that the PCollection at the reported index was assigned the output of a real transform.","Ensure the PCollection was produced within the same valid pipeline scope.","Use beam.TryExternal and handle the returned error instead of the panicking beam.External wrapper.","Add col.IsValid() checks before calling External."],"exampleFix":"// before\nvar input beam.PCollection\nbeam.External(s, urn, payload, []beam.PCollection{input}, outs, true)\n// after\ninput := beam.ParDo(s, &myFn{}, seed)\nif !input.IsValid() { log.Fatal(\"input pcollection invalid\") }\nbeam.External(s, urn, payload, []beam.PCollection{input}, outs, true)","handlingStrategy":"validation","validationCode":"for i, col := range ins {\n    if !col.IsValid() {\n        return fmt.Errorf(\"input pcollection %d invalid before External\", i)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := beam.TryExternal(s, urn, payload, ins, outs, true); err != nil {\n    return fmt.Errorf(\"external transform setup failed: %w\", err)\n}","preventionTips":["Never use zero-value beam.PCollection variables","Assign every PCollection from a real transform's output","Prefer Try* variants during pipeline development"],"tags":["beam","pipeline-construction","validation"],"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-20T03:17:13.778Z"}