{"record":{"id":"4b73b91ea1d0f846","repo":"apache/beam","slug":"experiment-worker-region-and-option-workerregion-are","errorCode":null,"errorMessage":"experiment worker_region and option workerRegion are mutually exclusive","messagePattern":"experiment worker_region and option workerRegion are mutually exclusive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/runners/dataflow/dataflowlib/job.go","lineNumber":421,"sourceCode":"\t\treturn errors.New(\"cannot use option zone with workerRegion; prefer either workerZone or workerRegion\")\n\t}\n\tif opts.Zone != \"\" && opts.WorkerZone != \"\" {\n\t\treturn errors.New(\"cannot use option zone with workerZone; prefer workerZone\")\n\t}\n\tif opts.WorkerZone != \"\" && opts.WorkerRegion != \"\" {\n\t\treturn errors.New(\"workerRegion and workerZone options are mutually exclusive\")\n\t}\n\n\thasExperimentWorkerRegion := false\n\tfor _, experiment := range opts.Experiments {\n\t\tif strings.HasPrefix(experiment, \"worker_region\") {\n\t\t\thasExperimentWorkerRegion = true\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif hasExperimentWorkerRegion && opts.WorkerRegion != \"\" {\n\t\treturn errors.New(\"experiment worker_region and option workerRegion are mutually exclusive\")\n\t}\n\tif hasExperimentWorkerRegion && opts.WorkerZone != \"\" {\n\t\treturn errors.New(\"experiment worker_region and option workerZone are mutually exclusive\")\n\t}\n\tif hasExperimentWorkerRegion && opts.Zone != \"\" {\n\t\treturn errors.New(\"experiment worker_region and option Zone are mutually exclusive\")\n\t}\n\n\tif opts.Zone != \"\" {\n\t\tlog.Warn(ctx, \"Option --zone is deprecated. Please use --workerZone instead.\")\n\t\topts.WorkerZone = opts.Zone\n\t\topts.Zone = \"\"\n\t}\n\n\tnumWorkers := opts.NumWorkers\n\tmaxNumWorkers := opts.MaxNumWorkers\n\tif numWorkers < 0 {\n\t\treturn fmt.Errorf(\"num_workers (%d) cannot be negative\", numWorkers)","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/dataflow/dataflowlib/job.go#L403-L439","documentation":"validateWorkerSettings rejects a job that enables the worker_region experiment (an --experiment=worker_region=... flag) while also setting the workerRegion option. The same setting is expressed twice via different mechanisms, which the library treats as conflicting.","triggerScenarios":"JobOptions.Experiments contains a string with prefix \"worker_region\" (e.g. \"worker_region=us-central1\") AND opts.WorkerRegion != \"\" during Translate.","commonSituations":"Pipeline code adding the experiment programmatically while the launcher also passes --worker_region; template defaults carrying the experiment flag plus new-style options.","solutions":["Remove the worker_region experiment from --experiments and set only the --worker_region option (preferred modern form).","Or remove the --worker_region option and keep only the experiment if targeting an older setup.","Dedupe experiments lists so the same placement is not declared twice."],"exampleFix":"// before\n// --experiment=worker_region=us-central1 --worker_region=us-central1\n// after\n// --worker_region=us-central1","handlingStrategy":"validation","validationCode":"hasExp := false\nfor _, e := range opts.Experiments {\n    if strings.HasPrefix(e, \"worker_region\") { hasExp = true }\n}\nif hasExp && opts.WorkerRegion != \"\" {\n    // drop the experiment; the option form is preferred\n    filtered := opts.Experiments[:0]\n    for _, e := range opts.Experiments { if !strings.HasPrefix(e, \"worker_region\") { filtered = append(filtered, e) } }\n    opts.Experiments = filtered\n}","typeGuard":null,"tryCatchPattern":"if err := dataflowlib.ValidateWorkerSettings(ctx, opts); err != nil && strings.Contains(err.Error(), \"experiment worker_region and option workerRegion\") {\n    // remove the experiment flag and retry with the option form\n}","preventionTips":["Use the --worker_region option, never the worker_region experiment, in new pipelines.","Dedupe experiments lists after merging defaults and user flags.","Review pipeline templates for legacy --experiment=worker_region=... entries."],"tags":["dataflow","gcp","configuration","experiments"],"backgroundTag":"mutually-exclusive-options","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"}