apache/beam · error · ValueError

Unrecognized type_info: {type_info!r}

Error message

Unrecognized type_info: {type_info!r}

What it means

generate_yaml_docs.py's _fake_value builds example fake values for Beam schema types when generating YAML docs. When the Beam FieldType's WhichOneof('type_info') returns a string the function does not handle, it raises ValueError with the unrecognized type_info. This means the docs generator encountered a Beam schema type (e.g. a newly added proto type) it has no fake-value rendering for.

Source

Thrown at sdks/python/apache_beam/yaml/generate_yaml_docs.py:89

    ]
  elif type_info == "map_type":
    if beam_type.map_type.key_type.atomic_type == schema_pb2.STRING:
      return {
          'a': _fake_value(name + '_value_a', beam_type.map_type.value_type),
          'b': _fake_value(name + '_value_b', beam_type.map_type.value_type),
          'c': '...',
      }
    else:
      return {
          _fake_value(name + '_key', beam_type.map_type.key_type): _fake_value(
              name + '_value', beam_type.map_type.value_type)
      }
  elif type_info == "row_type":
    return _fake_row(beam_type.row_type.schema)
  elif type_info == "logical_type":
    return name
  else:
    raise ValueError(f"Unrecognized type_info: {type_info!r}")


def _fake_row(schema):
  if schema is None:
    return '...'
  return {f.name: _fake_value(f.name, f.type) for f in schema.fields}


def pretty_example(provider, t, base_t=None):
  spec = {'type': base_t or t}
  try:
    requires_inputs = provider.requires_inputs(t, {})
  except Exception:
    requires_inputs = False
  if requires_inputs:
    spec['input'] = '...'
  config_schema = provider.config_schema(t)
  if config_schema is None or config_schema.fields:

View on GitHub (pinned to 12126d8942)

Solutions

  1. Add an elif branch in _fake_value handling the missing type_info and returning an appropriate fake value
  2. Check Beam schema proto docs for the type_info string and map it to a sensible placeholder
  3. Pin/align the Beam version so the docs generator matches the schema proto version in use

Example fix

# before
  elif type_info == "logical_type":
    return name
  else:
    raise ValueError(f"Unrecognized type_info: {type_info!r}")
# after
  elif type_info == "logical_type":
    return name
  elif type_info == "enum_type":
    return next(iter(beam_type.enum_type.enum_options), 'ENUM')
  else:
    raise ValueError(f"Unrecognized type_info: {type_info!r}")
Defensive patterns

Strategy: validation

Validate before calling

HANDLED = {'atomic_type','array_type','iterable_type','map_type','row_type','logical_type'}
unsupported = [t.WhichOneof('type_info') for t in all_field_types(beam_schema) if t.WhichOneof('type_info') not in HANDLED]
if unsupported:
    raise ValueError(f'Docs generator cannot render type_info: {unsupported}')

Type guard

def is_supported_for_docs(beam_type) -> bool:
    return beam_type.WhichOneof('type_info') in {'atomic_type','array_type','iterable_type','map_type','row_type','logical_type'}

Try / catch

try:
    fake = _fake_value(name, beam_type)
except ValueError as e:
    logging.warning('Skipping example for %s: %s', name, e)
    fake = '...'

Prevention

When it happens

Trigger: Calling _fake_value (directly or via _fake_row while faking a row schema) with a Beam FieldType whose type_info discriminator is not one of the handled branches (atomic, array, iterable, map, row_type, logical_type, etc.), e.g. enum_type or duration/micros-int types added in newer Beam proto versions.

Common situations: Running the YAML docs generation over transforms whose inferred schemas use newer or unusual Beam types; Beam proto version drift where a new type_info kind appears before generate_yaml_docs.py was updated.

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/7294581747b9c27f. Report an issue: GitHub.