apache/beam · error · ValueError

Invalid DisplayDataItem. Value

Error message

Invalid DisplayDataItem. Value {} is of an unsupported type.

What it means

apache_beam.transforms.display.DisplayDataItem.is_valid() validates that a display-data item has a known type. When self.type is None (the value was not one of the recognized primitive types), it raises this ValueError, typically surfaced from get_dict() during pipeline serialization.

Solutions

  1. Pass a supported primitive: convert the value with str(), int(), float(), or bool before creating the DisplayDataItem
  2. If the value is optional, skip emitting the item instead of building one with an unsupported value (also note value must not be None)
  3. Check that you are not overriding 'type' accidentally by passing an unsupported keyword

Example fix

// before
yield DisplayDataItem(my_custom_obj, label='cfg')
// after
yield DisplayDataItem(str(my_custom_obj), label='cfg')
Defensive patterns

Strategy: validation

Validate before calling

def ensure_displayable(v):
    if v is None or not isinstance(v, (str, int, float, bool)):
        raise TypeError(f'Non-displayable value {v!r}; coerce to str/int/float/bool')
    return v

Type guard

def is_display_data_type(v) -> bool:
    return isinstance(v, (str, int, float, bool))

Try / catch

try:
    d = item.get_dict()
except ValueError as e:
    logger.warning('dropping display data: %s', e)
    d = None

Prevention

When it happens

Trigger: Constructing a DisplayDataItem with a value whose type is not supported (e.g. a custom object, dict, or list) so that the inferred self.type ends up None, then calling is_valid() (via get_dict()).

Common situations: A custom DoFn's display_data() returns an unrecognized object type, or a value that subclasses a supported type indirectly; also stale pickles/protobufs where type was lost.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at sdks/python/apache_beam/transforms/display.py:347

    """ Checks that all the necessary fields of the :class:`DisplayDataItem`
    are filled in. It checks that neither key, namespace, value or type are
    :data:`None`.

    Raises:
      ValueError: If the item does not have a key, namespace,
        value or type.
    """
    if self.key is None:
      raise ValueError(
          'Invalid DisplayDataItem %s. Key must not be None.' % self)
    if self.namespace is None:
      raise ValueError(
          'Invalid DisplayDataItem %s. Namespace must not be None' % self)
    if self.value is None:
      raise ValueError(
          'Invalid DisplayDataItem %s. Value must not be None' % self)
    if self.type is None:
      raise ValueError(
          'Invalid DisplayDataItem. Value {} is of an unsupported type.'.format(
              self.value))

  def _get_dict(self):
    res = {
        'key': self.key,
        'namespace': self.namespace,
        'type': self.type if self.type != 'CLASS' else 'STRING'
    }
    # TODO: Python Class types should not be special-cased once
    # the Fn API is in.
    if self.url is not None:
      res['url'] = self.url
    if self.shortValue is not None:
      res['shortValue'] = self.shortValue
    if self.label is not None:
      res['label'] = self.label
    res['value'] = self._format_value(self.value, self.type)

View on GitHub (pinned to 12126d8942)