{"record":{"id":"7d45a640460230b5","repo":"apache/beam","slug":"invalid-scope-impulse","errorCode":null,"errorMessage":"Invalid scope","messagePattern":"Invalid scope","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/impulse.go","lineNumber":35,"sourceCode":"\nimport (\n\t\"github.com/apache/beam/sdks/v2/go/pkg/beam/core/graph\"\n)\n\n// Impulse emits a single empty []byte into the global window. The resulting\n// PCollection is a singleton of type []byte.\n//\n// The purpose of Impulse is to trigger another transform, such as\n// ones that take all information as side inputs.\nfunc Impulse(s Scope) PCollection {\n\treturn ImpulseValue(s, []byte{})\n}\n\n// ImpulseValue emits the supplied byte slice into the global window. The resulting\n// PCollection is a singleton of type []byte.\nfunc ImpulseValue(s Scope, value []byte) PCollection {\n\tif !s.IsValid() {\n\t\tpanic(\"Invalid scope\")\n\t}\n\tedge := graph.NewImpulse(s.real, s.scope, value)\n\tret := PCollection{edge.Output[0].To}\n\tret.SetCoder(NewCoder(ret.Type()))\n\treturn ret\n}\n","sourceCodeStart":17,"sourceCodeEnd":42,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/impulse.go#L17-L42","documentation":"beam.ImpulseValue (and Impulse) requires a valid Scope to attach the impulse node to the pipeline graph. If the Scope was created zero-valued or is otherwise invalid, the library panics because the edge cannot be added.","triggerScenarios":"Calling beam.Impulse or beam.ImpulseValue with a Scope from beam.Scope(root) where root is invalid, or a zero-value Scope struct.","commonSituations":"Constructing a pipeline inside a function that never initialized the root (beam.NewPipeline), or using a Scope after the pipeline construction has gone wrong in a custom DoFn/transform.","solutions":["Create the pipeline with beam.NewPipeline() and derive the scope via beam.Scope(pipeline).","Ensure the Scope passed down to helper functions comes from a valid parent, not a zero-value struct.","Check s.IsValid() before calling ImpulseValue to fail gracefully."],"exampleFix":"// before\nvar s beam.Scope\npc := beam.ImpulseValue(s, data) // panics\n// after\np := beam.NewPipeline()\ns := beam.Scope(p)\npc := beam.ImpulseValue(s, data)","handlingStrategy":"validation","validationCode":"if !s.IsValid() {\n    return errors.New(\"scope must come from beam.Scope(beam.NewPipeline())\")\n}","typeGuard":null,"tryCatchPattern":"func safeImpulse(s beam.Scope, v []byte) (pc beam.PCollection, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"ImpulseValue failed: %v\", r)\n        }\n    }()\n    return beam.ImpulseValue(s, v), nil\n}","preventionTips":["Always derive scopes from a pipeline built with beam.NewPipeline().","Check s.IsValid() before graph-building calls in helpers."],"tags":["go","apache-beam","invalid-scope"],"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"}