apache/beam · error · ValueError

Unknown algorithm . Supported algorithms are "builtin" or…

Error message

Unknown algorithm %s. Supported algorithms are "builtin" or "lcg".

What it means

get_generator selects a synthetic record generator by algorithm name; only 'builtin' and 'lcg' are supported. Any other value raises ValueError. Note the message uses %-style args in raise (an upstream quirk — the args are attached to the exception rather than interpolated in some versions).

Solutions

  1. Use algorithm='builtin' or algorithm='lcg'
  2. Fix the option/config value feeding the algorithm parameter
  3. Check casing — the comparison is exact lowercase

Example fix

// before
get_generator('lcg ', ...)  # trailing space
// after
get_generator('lcg', ...)
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED = {'builtin', 'lcg'}
if algorithm not in SUPPORTED:
    raise ValueError(f'algorithm must be one of {SUPPORTED}')

Type guard

def is_supported_algorithm(a):
    return a in ('builtin', 'lcg')

Try / catch

try:
    gen = get_generator(algorithm, byte_size, seed)
except ValueError as e:
    _LOGGER.error('%s; defaulting to builtin', e)
    gen = get_generator('builtin', byte_size, seed)

Prevention

When it happens

Trigger: Calling get_generator (directly or via _gen_kv_pair/read/process) with algorithm='random', an empty string, or a mis-parsed pipeline option value.

Common situations: Typo in the --synthetic-algorithm-like option; config JSON with an algorithm field outside the supported set; copy-pasting an algorithm name from a different tool.

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/3b87d5b7192f4126. Report an issue: GitHub.

Appendix: source

Thrown at sdks/python/apache_beam/testing/synthetic_pipeline.py:92

  """A subclass of `random.Random` from the Python Standard Library that
  provides a method returning random bytes of arbitrary length.
  """

  # `numpy.random.RandomState` does not provide `random()` method, we keep this
  # for compatibility reasons.
  random_sample = Random.random


def get_generator(seed: Optional[int] = None, algorithm: Optional[str] = None):
  if algorithm is None or algorithm == 'builtin':
    return _Random(seed)
  elif algorithm == 'lcg':
    generator = LCGenerator()
    if seed is not None:
      generator.seed(seed)
    return generator
  else:
    raise ValueError(
        'Unknown algorithm %s. Supported algorithms are "builtin" or "lcg".',
        algorithm)


def parse_byte_size(s):
  suffixes = 'BKMGTP'
  if s[-1] in suffixes:
    return int(float(s[:-1]) * 1024**suffixes.index(s[-1]))

  return int(s)


def div_round_up(a, b):
  """Return ceil(a/b)."""
  return int(math.ceil(float(a) / b))


def rotate_key(element):

View on GitHub (pinned to 12126d8942)