apache/beam · error

unable to find default Go environment with ID

Error message

unable to find default Go environment with ID %q

What it means

UpdateDefaultEnvWorkerType looks up the default Go environment (fixed defaultEnvId) in the pipeline's component map to swap in a worker artifact payload. This error is thrown when that environment entry is missing from the pipeline components.

Solutions

  1. Ensure the pipeline was built by the Go SDK so the default Go environment exists before calling UpdateDefaultEnvWorkerType.
  2. Check the environments map (p.GetComponents().GetEnvironments()[defaultEnvId]) before mutating and log available env IDs.
  3. Regenerate the pipeline proto with a matching Beam SDK version instead of hand-editing component IDs.

Example fix

// before
err := graphx.UpdateDefaultEnvWorkerType(urn, payload, pipe)
// after
if _, ok := pipe.GetComponents().GetEnvironments()["go"]; !ok {
    return errors.New("pipeline has no default Go environment; rebuild with Go SDK")
}
err := graphx.UpdateDefaultEnvWorkerType(urn, payload, pipe)
Defensive patterns

Strategy: validation

Validate before calling

if _, ok := pipe.GetComponents().GetEnvironments()[defaultEnvId]; !ok {
    return errors.New("pipeline missing default Go environment; rebuild with Go SDK")
}

Try / catch

if err := graphx.UpdateDefaultEnvWorkerType(urn, payload, pipe); err != nil {
    log.Fatalf("worker payload injection failed: %v", err)
}

Prevention

When it happens

Trigger: Calling UpdateDefaultEnvWorkerType (e.g. in custom worker binary/container injection paths) on a pipeline whose components.Environments map lacks the default Go environment ID.

Common situations: Mutating a pipeline proto produced/modified by another SDK or runner that renamed or removed the Go environment; a prior translation step dropped or re-IDed environments; running cross-language pipelines where the Go env was not embedded.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/a0e10310d24e5e65. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/core/runtime/graphx/translate.go:1510

	return fmt.Sprintf("e%v", edge.ID())
}

func nodeID(n *graph.Node) string {
	return fmt.Sprintf("n%v", n.ID())
}

func scopeID(s *graph.Scope) string {
	return fmt.Sprintf("s%v", s.ID())
}

// UpdateDefaultEnvWorkerType is so runners can update the pipeline's default environment
// with the correct artifact type and payload for the Go worker binary.
func UpdateDefaultEnvWorkerType(typeUrn string, pyld []byte, p *pipepb.Pipeline) error {
	// Get the Go environment out.
	envs := p.GetComponents().GetEnvironments()
	env, ok := envs[defaultEnvId]
	if !ok {
		return errors.Errorf("unable to find default Go environment with ID %q", defaultEnvId)
	}
	for _, dep := range env.GetDependencies() {
		if dep.RoleUrn != URNArtifactGoWorkerRole {
			continue
		}
		dep.TypeUrn = typeUrn
		dep.TypePayload = pyld
		return nil
	}
	return errors.Errorf("unable to find dependency with %q role in environment with ID %q,", URNArtifactGoWorkerRole, defaultEnvId)
}

// UserStateCoderID returns the coder id of a user state
func UserStateCoderID(ps state.PipelineState) string {
	return fmt.Sprintf("val_%v", ps.StateKey())
}

// UserStateKeyCoderID returns the key coder id of a user state

View on GitHub (pinned to 12126d8942)