apache/beam · error · ValueError

Unrecognized type_info

Error message

Unrecognized type_info: {type_info!r}

What it means

_arrow_type_from_beam_fieldtype switches on the FieldType's type_info oneof (atomic_type, array_type, map_type, row_type, logical_type). If type_info is anything else (or None for a malformed/empty FieldType), the code raises ValueError with the unrecognized value's repr.

Solutions

  1. Ensure every FieldType has exactly one type_info set (atomic_type, array_type, map_type, row_type)
  2. Re-serialize/deserialize with matching Beam versions so unknown type_info variants aren't dropped
  3. Validate the schema protobuf before conversion (check WhichOneof('type_info') is not None)

Example fix

// before
ft = schema_pb2.FieldType()  # no type_info set
// after
ft = schema_pb2.FieldType(atomic_type=schema_pb2.STRING)
Defensive patterns

Strategy: validation

Validate before calling

if ft.WhichOneof('type_info') is None:
    raise TypeError('FieldType has no type_info set; must be one of atomic/array/map/row/logical')

Type guard

def has_type_info(ft) -> bool:
    return ft.WhichOneof('type_info') is not None

Try / catch

try:
    arrow_type = _arrow_type_from_beam_fieldtype(ft)
except ValueError as e:
    if str(e).startswith('Unrecognized type_info'):
        raise SchemaError('malformed FieldType: no known type_info oneof set') from e
    raise

Prevention

When it happens

Trigger: Passing a schema_pb2.FieldType with no type_info set (empty default FieldType) or a corrupted/forward-compat protobuf field from a newer Beam version through arrow conversion.

Common situations: Building FieldTypes manually and forgetting to set any type; deserializing schemas from a newer Beam/other SDK with a type_info this version doesn't know; protobuf default-constructed fields.

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

Appendix: source

Thrown at sdks/python/apache_beam/typehints/arrow_type_compatibility.py:293

    output_arrow_type = pa.list_(
        _arrow_field_from_beam_fieldtype(
            beam_fieldtype.array_type.element_type))
  elif type_info == "map_type":
    output_arrow_type = _make_arrow_map(beam_fieldtype.map_type)
  elif type_info == "row_type":
    schema = beam_fieldtype.row_type.schema
    # Note schema id and options are handled at the arrow field level, they are
    # added at field-level metadata.
    output_arrow_type = pa.struct(
        [_arrow_field_from_beam_field(field) for field in schema.fields])
  elif type_info == "logical_type":
    # TODO(https://github.com/apache/beam/issues/23817): Add support for logical
    # types.
    raise NotImplementedError(
        "Beam logical types are not currently supported "
        "in arrow_type_compatibility.")
  else:
    raise ValueError(f"Unrecognized type_info: {type_info!r}")

  return output_arrow_type


class PyarrowBatchConverter(BatchConverter):
  def __init__(self, element_type: RowTypeConstraint):
    super().__init__(pa.Table, element_type)
    self._beam_schema = typing_to_runner_api(element_type).row_type.schema
    arrow_schema = arrow_schema_from_beam_schema(self._beam_schema)

    self._arrow_schema = arrow_schema

  @staticmethod
  def from_typehints(element_type,
                     batch_type) -> Optional['PyarrowBatchConverter']:
    assert batch_type == pa.Table

    if not isinstance(element_type, RowTypeConstraint):

View on GitHub (pinned to 12126d8942)