{"record":{"id":"eb14c0491edc99e7","repo":"apache/beam","slug":"unable-to-find-dependency-with-q-role-in-environment-with-id","errorCode":null,"errorMessage":"unable to find dependency with %q role in environment with ID %q,","messagePattern":"unable to find dependency with %q role in environment with ID %q,","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/translate.go","lineNumber":1520,"sourceCode":"\n// UpdateDefaultEnvWorkerType is so runners can update the pipeline's default environment\n// with the correct artifact type and payload for the Go worker binary.\nfunc UpdateDefaultEnvWorkerType(typeUrn string, pyld []byte, p *pipepb.Pipeline) error {\n\t// Get the Go environment out.\n\tenvs := p.GetComponents().GetEnvironments()\n\tenv, ok := envs[defaultEnvId]\n\tif !ok {\n\t\treturn errors.Errorf(\"unable to find default Go environment with ID %q\", defaultEnvId)\n\t}\n\tfor _, dep := range env.GetDependencies() {\n\t\tif dep.RoleUrn != URNArtifactGoWorkerRole {\n\t\t\tcontinue\n\t\t}\n\t\tdep.TypeUrn = typeUrn\n\t\tdep.TypePayload = pyld\n\t\treturn nil\n\t}\n\treturn errors.Errorf(\"unable to find dependency with %q role in environment with ID %q,\", URNArtifactGoWorkerRole, defaultEnvId)\n}\n\n// UserStateCoderID returns the coder id of a user state\nfunc UserStateCoderID(ps state.PipelineState) string {\n\treturn fmt.Sprintf(\"val_%v\", ps.StateKey())\n}\n\n// UserStateKeyCoderID returns the key coder id of a user state\nfunc UserStateKeyCoderID(ps state.PipelineState) string {\n\treturn fmt.Sprintf(\"key_%v\", ps.StateKey())\n}\n","sourceCodeStart":1502,"sourceCodeEnd":1532,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/translate.go#L1502-L1532","documentation":"After finding the default Go environment, UpdateDefaultEnvWorkerType iterates its dependencies looking for one with the Go worker role URN to overwrite with the new artifact type/payload. This error is thrown when the environment exists but contains no dependency carrying URNArtifactGoWorkerRole.","triggerScenarios":"Calling UpdateDefaultEnvWorkerType on a pipeline whose default Go environment's dependency list has no entry with RoleUrn == URNArtifactGoWorkerRole (loop falls through without returning).","commonSituations":"Custom environment construction omitted the Go worker artifact dependency; a preprocessing step stripped or re-tagged dependencies; cross-language merging replaced the environment contents.","solutions":["Verify the Go environment includes the artifact dependency with the Go worker role URN (URNArtifactGoWorkerRole).","Rebuild the pipeline with the stock Go SDK environment rather than a hand-constructed one.","Add the dependency with the correct role URN to the environment before calling UpdateDefaultEnvWorkerType."],"exampleFix":"// before\n// env built manually without role-tagged deps\nenv := pipepb.NewEnvironment(...)\n// after\ndeps = append(deps, &pipepb.ArtifactDependency{\n    TypeUrn: graphx.URNArtifactFileType,\n    RoleUrn: graphx.URNArtifactGoWorkerRole,\n})\nenv.Dependencies = deps","handlingStrategy":"validation","validationCode":"for _, dep := range env.GetDependencies() {\n    if dep.GetRoleUrn() == graphx.URNArtifactGoWorkerRole {\n        return nil // ok\n    }\n}\nreturn errors.New(\"environment lacks Go worker role dependency\")","typeGuard":null,"tryCatchPattern":"if err := graphx.UpdateDefaultEnvWorkerType(urn, payload, pipe); err != nil {\n    log.Fatalf(\"no Go worker role dependency: %v\", err)\n}","preventionTips":["Use stock Go SDK environments; include the Go worker role dependency when constructing environments.","Audit any preprocessing that rewrites environment dependencies.","Keep role URNs from the graphx package rather than hardcoding strings."],"tags":["go","apache-beam","environment","artifacts"],"backgroundTag":"entity-not-found","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"}