{"record":{"id":"f055a9c63880d69a","repo":"apache/beam","slug":"cannot-use-option-zone-with-workerzone-prefer-workerzone","errorCode":null,"errorMessage":"cannot use option zone with workerZone; prefer workerZone","messagePattern":"cannot use option zone with workerZone; prefer workerZone","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/runners/dataflow/dataflowlib/job.go","lineNumber":406,"sourceCode":"\taddIfNonEmpty(\"worker_zone\", opts.WorkerZone)\n\taddIfNonEmpty(\"network\", opts.Network)\n\taddIfNonEmpty(\"subnetwork\", opts.Subnetwork)\n\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\")","sourceCodeStart":388,"sourceCodeEnd":424,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/dataflow/dataflowlib/job.go#L388-L424","documentation":"validateWorkerSettings rejects a configuration that sets both the deprecated --zone option and the newer --worker_zone option. Both request zonal placement, so they conflict; the library asks users to use worker_zone only, as zone is deprecated.","triggerScenarios":"JobOptions with Zone != \"\" AND WorkerZone != \"\"; e.g. passing --zone=us-central1-a together with --worker_zone=us-central1-b, or a wrapper that sets both fields before Translate.","commonSituations":"Migrating scripts from --zone to --worker_zone where the old flag was left in place; CI configs accumulating flags across Beam version upgrades.","solutions":["Delete --zone and keep only --worker_zone.","Ensure zone and worker_zone point at the same zone if tooling sets both automatically — or strip the legacy flag.","Heed the deprecation: always prefer --worker_zone going forward."],"exampleFix":"// before\n// --zone=us-central1-a --worker_zone=us-central1-a\n// after\n// --worker_zone=us-central1-a","handlingStrategy":"validation","validationCode":"if opts.Zone != \"\" && opts.WorkerZone != \"\" {\n    opts.Zone = \"\" // worker_zone wins; zone is deprecated\n}","typeGuard":null,"tryCatchPattern":"if err := dataflowlib.ValidateWorkerSettings(ctx, opts); err != nil && strings.Contains(err.Error(), \"option zone with workerZone\") {\n    // drop deprecated zone flag and retry\n}","preventionTips":["Delete --zone from all scripts/templates; use --worker_zone only.","In wrappers, copy zone into worker_zone automatically for backward compatibility.","Grep repos and pipeline templates for \"--zone=\" during Beam upgrades."],"tags":["dataflow","gcp","configuration","deprecated-flag"],"backgroundTag":"mutually-exclusive-flags","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"}