apache/beam · error

no Google Cloud region specified. Use --region=

Error message

no Google Cloud region specified. Use --region=<region>. See https://cloud.google.com/dataflow/docs/concepts/regional-endpoints

What it means

The Dataflow runner requires a Google Cloud region because Dataflow is a regional service. getJobOptions calls gcpopts.GetRegion(ctx) and returns this error when neither the --region flag nor its environment fallback is set, linking to the regional-endpoints documentation.

Solutions

  1. Pass --region=<region> (e.g. us-central1) to the pipeline
  2. Export GOOGLE_CLOUD_REGION or set the region via gcpopts before Execute
  3. Pick a region co-located with your GCS staging bucket to avoid cross-region costs

Example fix

// before
--runner=dataflow --project=p --staging_location=gs://b/s
// after
--runner=dataflow --project=p --region=us-central1 --staging_location=gs://b/s
Defensive patterns

Strategy: validation

Validate before calling

if region == "" {
    return errors.New("set --region (e.g. us-central1)")
}

Prevention

When it happens

Trigger: Executing a Dataflow pipeline without --region=<region> and without the environment/attribute fallback for region (e.g. GOOGLE_CLOUD_REGION or pipeline option) being set.

Common situations: Old scripts written before region became mandatory; multi-region orgs where the default region assumption no longer applies; CI environments missing the region variable.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

Thrown at sdks/go/pkg/beam/runners/dataflow/dataflow.go:276

func isFlagPassed(name string) bool {
	found := false
	flag.Visit(func(f *flag.Flag) {
		if f.Name == name {
			found = true
		}
	})
	return found
}

func getJobOptions(ctx context.Context, streaming bool) (*dataflowlib.JobOptions, error) {
	project := gcpopts.GetProjectFromFlagOrEnvironment(ctx)
	if project == "" {
		return nil, errors.New("no Google Cloud project specified. Use --project=<project>")
	}
	region := gcpopts.GetRegion(ctx)
	if region == "" {
		return nil, errors.New("no Google Cloud region specified. Use --region=<region>. See https://cloud.google.com/dataflow/docs/concepts/regional-endpoints")
	}
	if *stagingLocation == "" {
		return nil, errors.New("no GCS staging location specified. Use --staging_location=gs://<bucket>/<path>")
	}

	checkSoftDeletePolicyEnabled(ctx, *stagingLocation, "staging_location")

	var jobLabels map[string]string
	if *labels != "" {
		if err := json.Unmarshal([]byte(*labels), &jobLabels); err != nil {
			return nil, errors.Wrapf(err, "error reading --label flag as JSON")
		}
	}

	if *cpuProfiling != "" {
		perf.EnableProfCaptureHook("gcs_profile_writer", *cpuProfiling)
	}

View on GitHub (pinned to 12126d8942)