{"record":{"id":"cf42a93ebdb03c2a","repo":"apache/beam","slug":"workerregion-and-workerzone-options-are-mutually-exclusive","errorCode":null,"errorMessage":"workerRegion and workerZone options are mutually exclusive","messagePattern":"workerRegion and workerZone options are mutually exclusive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/runners/dataflow/dataflowlib/job.go","lineNumber":409,"sourceCode":"\taddIfNonEmpty(\"machine_type\", opts.MachineType)\n\taddIfNonEmpty(\"container_images\", strings.Join(images, \",\"))\n\taddIfNonEmpty(\"temp_location\", opts.TempLocation)\n\n\tfor k, v := range opts.Options.Options {\n\t\tret = append(ret, newDisplayData(k, \"\", \"go_options\", v))\n\t}\n\treturn ret\n}\n\nfunc validateWorkerSettings(ctx context.Context, opts *JobOptions) error {\n\tif opts.Zone != \"\" && opts.WorkerRegion != \"\" {\n\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\")","sourceCodeStart":391,"sourceCodeEnd":427,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/dataflow/dataflowlib/job.go#L391-L427","documentation":"validateWorkerSettings rejects a configuration that sets both workerRegion and workerZone options. Dataflow placement must be either regional or zonal, not both; the two options are mutually exclusive.","triggerScenarios":"JobOptions with WorkerZone != \"\" AND WorkerRegion != \"\" — e.g. --worker_region=us-central1 with --worker_zone=us-central1-a — during Translate.","commonSituations":"Combining a shared options file that sets worker_region with a per-job flag setting worker_zone; copy-paste from mixed documentation examples.","solutions":["Keep only one: drop --worker_zone to run regionally, or drop --worker_region and set --worker_zone for a specific zone.","If regional is intended, ensure experiments do not add worker_region alongside a worker_zone (the experiment form is checked separately).","Centralize placement options in one config source to avoid merging both."],"exampleFix":"// before\n// --worker_region=us-central1 --worker_zone=us-central1-a\n// after\n// --worker_zone=us-central1-a   (or --worker_region=us-central1)","handlingStrategy":"validation","validationCode":"if opts.WorkerZone != \"\" && opts.WorkerRegion != \"\" {\n    return fmt.Errorf(\"set only one of worker_region (%q) or worker_zone (%q)\", opts.WorkerRegion, opts.WorkerZone)\n}","typeGuard":null,"tryCatchPattern":"if err := dataflowlib.ValidateWorkerSettings(ctx, opts); err != nil && strings.Contains(err.Error(), \"mutually exclusive\") {\n    // decide placement: prefer worker_zone if both set\n}","preventionTips":["Keep region/zone placement in exactly one config source.","Validate option sets before merging user flags with defaults.","Document that worker_region and worker_zone cannot be combined."],"tags":["dataflow","gcp","configuration","flags"],"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"}