apache/beam · error · ValueError

Unknown Cloud Build Machine Type option, please specify one…

Error message

Unknown Cloud Build Machine Type option, please specify one of [n1-highcpu-8, n1-highcpu-32, e2-highcpu-8, e2-highcpu-32].

What it means

_get_cloud_build_machine_type_enum maps a machine type string to the google-cloud-build MachineType enum. If the provided machine_type string (case-insensitive) is not one of the four supported n1/e2-highcpu options, ValueError lists the accepted values.

Solutions

  1. Use exactly one of: n1-highcpu-8, n1-highcpu-32, e2-highcpu-8, e2-highcpu-32 (any case)
  2. Check your pipeline option/config supplying cloud_build_machine_type for typos
  3. Remove the machine type option to use the Cloud Build default if unsure

Example fix

// before
machine_type = 'n1-highcpu-16'
// after
machine_type = 'n1-highcpu-32'
Defensive patterns

Strategy: validation

Validate before calling

VALID = {'n1-highcpu-8', 'n1-highcpu-32', 'e2-highcpu-8', 'e2-highcpu-32'}
mt = (options.cloud_build_machine_type or '').lower()
assert mt in VALID, f'cloud_build_machine_type {mt!r} invalid; choose from {sorted(VALID)}'

Type guard

def is_valid_machine_type(mt: str) -> bool:
    return mt.lower() in {'n1-highcpu-8', 'n1-highcpu-32', 'e2-highcpu-8', 'e2-highcpu-32'}

Try / catch

try:
    builder = SdkContainerImageBuilder(..., cloud_build_machine_type=mt)
except ValueError as e:
    if 'Unknown Cloud Build Machine Type' in str(e):
        logger.warning('%s; using default machine type', e)
        builder = SdkContainerImageBuilder(..., cloud_build_machine_type=None)
    else:
        raise

Prevention

When it happens

Trigger: Constructing the Cloud Build container builder (__init__ path) with a cloud_build_machine_type value other than n1-highcpu-8, n1-highcpu-32, e2-highcpu-8, or e2-highcpu-32 (case-insensitive).

Common situations: Passing N1-HIGHCPU-8 variants with dashes misspelled (e.g. 'n1-highcpu-16' which is not mapped), 'standard', 'e2-standard-8', or empty strings from config files.

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


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

Appendix: source

Thrown at sdks/python/apache_beam/runners/portability/sdk_container_builder.py:371

      tar.add(source_dir, arcname=SOURCE_FOLDER)

  @staticmethod
  def _get_cloud_build_machine_type_enum(machine_type: str):
    from google.cloud.devtools.cloudbuild_v1 import types as cloud_build_types
    if not machine_type:
      return None
    mappings = {
        'n1-highcpu-8': cloud_build_types.BuildOptions.MachineType.N1_HIGHCPU_8,
        'n1-highcpu-32': cloud_build_types.BuildOptions.MachineType.
        N1_HIGHCPU_32,
        'e2-highcpu-8': cloud_build_types.BuildOptions.MachineType.E2_HIGHCPU_8,
        'e2-highcpu-32': cloud_build_types.BuildOptions.MachineType.
        E2_HIGHCPU_32
    }
    if machine_type.lower() in mappings:
      return mappings[machine_type.lower()]
    else:
      raise ValueError(
          'Unknown Cloud Build Machine Type option, please specify one of '
          '[n1-highcpu-8, n1-highcpu-32, e2-highcpu-8, e2-highcpu-32].')

View on GitHub (pinned to 12126d8942)