apache/beam · critical
Beam has not been initialized. Call beam.Init() before…
Error message
Beam has not been initialized. Call beam.Init() before pipeline construction.
What it means
beam.Execute for the universal runner requires global SDK initialization (flags, job options, logging) performed by beam.Init(). If the program builds a pipeline and calls Execute before Init, the runner panics because job option flags and registration would be unset.
Solutions
- Call beam.Init() at the start of main(), before any pipeline construction or runner execution.
- Ensure beam.Init() runs after flag definitions but before flag.Parse-driven option consumption; place it before Execute.
- If using custom flags, still call beam.Init() (it parses Beam's job-option flags) or set job options explicitly.
- Restructure code that builds pipelines in package init() to defer building until after beam.Init() in main.
Example fix
// before
func main() {
p := beam.NewPipeline()
beam.Run(ctx, "portable", p) // panics: not initialized
}
// after
func main() {
beam.Init()
p := beam.NewPipeline()
beam.Run(ctx, "portable", p)
} Defensive patterns
Strategy: validation
Validate before calling
if !beam.Initialized() { beam.Init() } // before Execute/pipeline construction Try / catch
defer func(){ if r := recover(); r != nil && strings.Contains(fmt.Sprint(r), "Beam has not been initialized") { /* re-run with beam.Init() first */ } }() Prevention
- Always call beam.Init() at the top of main()
- Don't build pipelines in package init()
- Keep standard flag parsing so Beam job-option flags are registered
When it happens
Trigger: Calling universal.Execute (or running with --runner=portable) after constructing a pipeline but without ever calling beam.Init(); calling Execute in init() ordering contexts where beam.Init() hasn't run.
Common situations: Go binaries that parse flags late or use custom flag parsing and skip beam.Init(); test helpers that build pipelines at package init time; copying example code that omitted beam.Init().
Related errors
- Init hooks have already run. Register hook during init()…
- RegisterHeapCaptureHook
- RegisterProfCaptureHook
- RegisterTraceCaptureHook
- while executing Up for
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/e37b0ff46ec73954.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/runners/universal/universal.go:48
"github.com/apache/beam/sdks/v2/go/pkg/beam/internal/errors"
"github.com/apache/beam/sdks/v2/go/pkg/beam/log"
"github.com/apache/beam/sdks/v2/go/pkg/beam/options/jobopts"
"github.com/apache/beam/sdks/v2/go/pkg/beam/runners/universal/extworker"
"github.com/apache/beam/sdks/v2/go/pkg/beam/runners/universal/runnerlib"
"github.com/apache/beam/sdks/v2/go/pkg/beam/runners/vet"
)
func init() {
// Note that we also _ import harness/init to setup the remote execution hook.
beam.RegisterRunner("universal", Execute)
beam.RegisterRunner("PortableRunner", Execute)
beam.RegisterRunner("portable", Execute)
}
// Execute executes the pipeline on a universal beam runner.
func Execute(ctx context.Context, p *beam.Pipeline) (beam.PipelineResult, error) {
if !beam.Initialized() {
panic("Beam has not been initialized. Call beam.Init() before pipeline construction.")
}
if *jobopts.Strict {
log.Info(ctx, "Strict mode enabled, applying additional validation.")
if _, err := vet.Execute(ctx, p); err != nil {
return nil, errors.Wrap(err, "strictness check failed")
}
log.Info(ctx, "Strict mode validation passed.")
}
endpoint, err := jobopts.GetEndpoint()
if err != nil {
return nil, err
}
edges, _, err := p.Build()
if err != nil {
return nil, errView on GitHub (pinned to 12126d8942)