apache/beam · error · ValueError

Unrecognized type_info: {type_info!r}

Error message

Unrecognized type_info: {type_info!r}

What it means

json_to_row dispatches on the Beam FieldType's type_info discriminator; if it encounters a type_info string it does not handle (e.g. logical variants or newer proto types beyond row/array/iterable/map/logical), it raises ValueError with the unrecognized discriminator. This indicates the schema contains a type the JSON converter cannot translate.

Source

Thrown at sdks/python/apache_beam/yaml/json_utils.py:222

        for field in beam_type.row_type.schema.fields
    }

    def convert_row(value):
      kwargs = {}
      for name, convert in converters.items():
        if name in value:
          kwargs[name] = convert(value[name])
        elif field_nullable_status[name]:
          kwargs[name] = convert(None)
        else:
          raise KeyError(f"Missing required field: {name}")
      return beam.Row(**kwargs)

    return convert_row
  elif type_info == "logical_type":
    return lambda value: value
  else:
    raise ValueError(f"Unrecognized type_info: {type_info!r}")


def json_parser(
    beam_schema: schema_pb2.Schema,
    json_schema: Optional[dict[str,
                               Any]] = None) -> Callable[[bytes], beam.Row]:
  """Returns a callable converting Json strings to Beam rows of the given type.

  The input to the returned callable is expected to conform to the Json schema
  corresponding to this Beam type.
  """
  if json_schema is None:
    validate_fn = None
  else:
    cls = jsonschema.validators.validator_for(json_schema)
    cls.check_schema(json_schema)
    validate_fn = _PicklableFromConstructor(
        lambda: jsonschema.validators.validator_for(json_schema)

View on GitHub (pinned to 12126d8942)

Solutions

  1. Simplify the schema to JSON-representable types (atomic, array, map, row, logical)
  2. Extend json_to_row with a branch for the missing type_info
  3. Check the Beam version for known gaps and upgrade to a release that supports the type

Example fix

# before
schema: "enum<VALID,INVALID> status"
# after
schema: "string status"
Defensive patterns

Strategy: validation

Validate before calling

HANDLED = {'atomic_type','array_type','iterable_type','map_type','row_type','logical_type'}
def assert_json_convertible(beam_schema):
    bad = [f.name for f in beam_schema.fields if f.type.WhichOneof('type_info') not in HANDLED]
    if bad:
        raise ValueError(f'Fields not JSON-convertible: {bad}')

Type guard

def is_json_convertible(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:
    row = json_parser(beam_schema)(raw)
except ValueError as e:
    raise ValueError(f'Schema contains types unsupported by the JSON converter: {e}') from e

Prevention

When it happens

Trigger: A Beam schema containing a FieldType whose WhichOneof('type_info') is not one of the handled branches (atomic_type, array_type, iterable_type, map_type, row_type, logical_type) being processed by json_to_row or json_parser.

Common situations: Schemas with enum or newer proto types in a JSON-consuming yaml pipeline; Beam version drift introducing new type kinds before json_utils.py was extended.

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