apache/beam · error
invalid flex resource scheduling goal. Got %q; Use --flexrs_
Error message
invalid flex resource scheduling goal. Got %q; Use --flexrs_goal=(FLEXRS_UNSPECIFIED|FLEXRS_SPEED_OPTIMIZED|FLEXRS_COST_OPTIMIZED)
What it means
getJobOptions validates the --flexrs_goal flag against the three allowed Dataflow FlexRS values: FLEXRS_UNSPECIFIED, FLEXRS_SPEED_OPTIMIZED, and FLEXRS_COST_OPTIMIZED. Any other non-empty value is rejected with this error before the job is created. FlexRS only applies to batch jobs, so this is a strict enum check on user input.
Source
Thrown at sdks/go/pkg/beam/runners/dataflow/dataflow.go:306
}
}
if *cpuProfiling != "" {
perf.EnableProfCaptureHook("gcs_profile_writer", *cpuProfiling)
}
if *autoscalingAlgorithm != "" {
if *autoscalingAlgorithm != "NONE" && *autoscalingAlgorithm != "THROUGHPUT_BASED" {
return nil, errors.New("invalid autoscaling algorithm. Use --autoscaling_algorithm=(NONE|THROUGHPUT_BASED)")
}
}
if *flexRSGoal != "" {
switch *flexRSGoal {
case "FLEXRS_UNSPECIFIED", "FLEXRS_SPEED_OPTIMIZED", "FLEXRS_COST_OPTIMIZED":
// valid values
default:
return nil, errors.Errorf("invalid flex resource scheduling goal. Got %q; Use --flexrs_goal=(FLEXRS_UNSPECIFIED|FLEXRS_SPEED_OPTIMIZED|FLEXRS_COST_OPTIMIZED)", *flexRSGoal)
}
}
if !streaming && *transformMapping != "" {
return nil, errors.New("provided transform_name_mapping for a batch pipeline, did you mean to construct a streaming pipeline?")
}
if !*update && *transformMapping != "" {
return nil, errors.New("provided transform_name_mapping without setting the --update flag, so the pipeline would not be updated")
}
var updateTransformMapping map[string]string
if *transformMapping != "" {
if err := json.Unmarshal([]byte(*transformMapping), &updateTransformMapping); err != nil {
return nil, errors.Wrapf(err, "error reading --transform_name_mapping flag as JSON")
}
}
if *usePublicIPs == *noUsePublicIPs {
useSet := isFlagPassed("use_public_ips")
noUseSet := isFlagPassed("no_use_public_ips")
// If use_public_ips was explicitly set but no_use_public_ips was not, use that valueView on GitHub (pinned to 12126d8942)
Solutions
- Set --flexrs_goal to exactly one of FLEXRS_UNSPECIFIED, FLEXRS_SPEED_OPTIMIZED, or FLEXRS_COST_OPTIMIZED (uppercase, full prefix)
- Omit the --flexrs_goal flag if you do not need Flex Resource Scheduling
- Fix case sensitivity: the comparison is exact, so FLEXRS_COST_OPTIMIZED not cost_optimized
- Verify the flag value in your pipeline launcher script or CI configuration
Example fix
// before --flexrs_goal=cost_optimized // after --flexrs_goal=FLEXRS_COST_OPTIMIZED
Defensive patterns
Strategy: validation
Validate before calling
valid := map[string]bool{"FLEXRS_UNSPECIFIED": true, "FLEXRS_SPEED_OPTIMIZED": true, "FLEXRS_COST_OPTIMIZED": true}
if flexRSGoal != "" && !valid[flexRSGoal] {
return fmt.Errorf("unsupported flexrs goal: %s", flexRSGoal)
} Try / catch
if err := run(); err != nil {
if strings.Contains(err.Error(), "flexrs_goal") {
log.Fatalf("use FLEXRS_UNSPECIFIED|FLEXRS_SPEED_OPTIMIZED|FLEXRS_COST_OPTIMIZED: %v", err)
}
} Prevention
- Copy enum values verbatim from Dataflow docs (uppercase, FLEXRS_ prefix)
- Centralize the goal value in one config constant
- Omit the flag when FlexRS is not needed
- Add a startup check that rejects unknown goal strings early
When it happens
Trigger: Starting a pipeline with --flexrs_goal set to anything other than the three accepted enum strings, e.g. lowercase values, 'SPEED_OPTIMIZED' without the FLEXRS_ prefix, or a typo.
Common situations: Users passing lowercase 'cost_optimized', abbreviating to 'FLEXRS_COST', reusing values from other GCP APIs (e.g. Compute Engine scheduling enums), or setting the flag in streaming configs where it was copied from a batch template.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- invalid autoscaling algorithm. Use --autoscaling_algorithm=(
- provided transform_name_mapping without setting the --update
- exactly one of usePublicIPs and noUsePublicIPs must be true,
- error reading --label flag as JSON
- error reading --transform_name_mapping flag as JSON
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/0dec0bd19a649b30.
Report an issue: GitHub.