{"record":{"id":"0dec0bd19a649b30","repo":"apache/beam","slug":"invalid-flex-resource-scheduling-goal-got-q-use-flexrs-goal","errorCode":null,"errorMessage":"invalid flex resource scheduling goal. Got %q; Use --flexrs_goal=(FLEXRS_UNSPECIFIED|FLEXRS_SPEED_OPTIMIZED|FLEXRS_COST_OPTIMIZED)","messagePattern":"invalid flex resource scheduling goal\\. Got %q; Use --flexrs_goal=\\(FLEXRS_UNSPECIFIED\\|FLEXRS_SPEED_OPTIMIZED\\|FLEXRS_COST_OPTIMIZED\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/runners/dataflow/dataflow.go","lineNumber":306,"sourceCode":"\t\t}\n\t}\n\n\tif *cpuProfiling != \"\" {\n\t\tperf.EnableProfCaptureHook(\"gcs_profile_writer\", *cpuProfiling)\n\t}\n\n\tif *autoscalingAlgorithm != \"\" {\n\t\tif *autoscalingAlgorithm != \"NONE\" && *autoscalingAlgorithm != \"THROUGHPUT_BASED\" {\n\t\t\treturn nil, errors.New(\"invalid autoscaling algorithm. Use --autoscaling_algorithm=(NONE|THROUGHPUT_BASED)\")\n\t\t}\n\t}\n\n\tif *flexRSGoal != \"\" {\n\t\tswitch *flexRSGoal {\n\t\tcase \"FLEXRS_UNSPECIFIED\", \"FLEXRS_SPEED_OPTIMIZED\", \"FLEXRS_COST_OPTIMIZED\":\n\t\t\t// valid values\n\t\tdefault:\n\t\t\treturn nil, errors.Errorf(\"invalid flex resource scheduling goal. Got %q; Use --flexrs_goal=(FLEXRS_UNSPECIFIED|FLEXRS_SPEED_OPTIMIZED|FLEXRS_COST_OPTIMIZED)\", *flexRSGoal)\n\t\t}\n\t}\n\tif !streaming && *transformMapping != \"\" {\n\t\treturn nil, errors.New(\"provided transform_name_mapping for a batch pipeline, did you mean to construct a streaming pipeline?\")\n\t}\n\tif !*update && *transformMapping != \"\" {\n\t\treturn nil, errors.New(\"provided transform_name_mapping without setting the --update flag, so the pipeline would not be updated\")\n\t}\n\tvar updateTransformMapping map[string]string\n\tif *transformMapping != \"\" {\n\t\tif err := json.Unmarshal([]byte(*transformMapping), &updateTransformMapping); err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"error reading --transform_name_mapping flag as JSON\")\n\t\t}\n\t}\n\tif *usePublicIPs == *noUsePublicIPs {\n\t\tuseSet := isFlagPassed(\"use_public_ips\")\n\t\tnoUseSet := isFlagPassed(\"no_use_public_ips\")\n\t\t// If use_public_ips was explicitly set but no_use_public_ips was not, use that value","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/dataflow/dataflow.go#L288-L324","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n--flexrs_goal=cost_optimized\n// after\n--flexrs_goal=FLEXRS_COST_OPTIMIZED","handlingStrategy":"validation","validationCode":"valid := map[string]bool{\"FLEXRS_UNSPECIFIED\": true, \"FLEXRS_SPEED_OPTIMIZED\": true, \"FLEXRS_COST_OPTIMIZED\": true}\nif flexRSGoal != \"\" && !valid[flexRSGoal] {\n    return fmt.Errorf(\"unsupported flexrs goal: %s\", flexRSGoal)\n}","typeGuard":null,"tryCatchPattern":"if err := run(); err != nil {\n    if strings.Contains(err.Error(), \"flexrs_goal\") {\n        log.Fatalf(\"use FLEXRS_UNSPECIFIED|FLEXRS_SPEED_OPTIMIZED|FLEXRS_COST_OPTIMIZED: %v\", err)\n    }\n}","preventionTips":["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"],"tags":["go","dataflow","cli-flag","enum"],"backgroundTag":"invalid-enum-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}