apache/beam · error · ValueError
Invalid DisplayDataItem
Error message
Invalid DisplayDataItem %s. Value must not be None
What it means
DisplayDataItem.is_valid found self.value is None: display data items must carry an actual value (plus key, namespace, and type) to render in the Dataflow UI; this guard fires when an item was built without calling with_value or when the value expression evaluated to None.
Solutions
- Provide a concrete value: use a default (e.g. self.n or 0) instead of a possibly-None attribute.
- Omit the item entirely when the value is None (build the dict conditionally).
- Convert None to a sentinel string if the presence of the key matters.
Example fix
// before
def display_data(self):
return {'threshold': self.threshold} # may be None
// after
def display_data(self):
dd = {}
if self.threshold is not None:
dd['threshold'] = self.threshold
return dd Defensive patterns
Strategy: validation
Validate before calling
for item in display_data.items:
if getattr(item, 'value', None) is None:
raise ValueError('display data item missing value') Type guard
def item_has_value(item) -> bool:
return getattr(item, 'value', None) is not None Try / catch
try:
d = display_data.get_dict()
except ValueError as e:
if 'Value must not be None' in str(e):
drop_none_valued_items(display_data)
d = display_data.get_dict()
else:
raise Prevention
- Never return None-valued attributes from display_data()
- Build display data dicts conditionally
- Give config attributes sane non-None defaults
When it happens
Trigger: display_data() returns an item whose value resolves to None (e.g. an unset attribute used directly as the value) and the DisplayData is later validated via get_dict()/is_valid().
Common situations: Returning an uninitialized instance attribute from display_data(); optional config values that end up None; constructing DisplayDataItem with value=None explicitly.
Related errors
- Invalid DisplayDataItem
- Invalid DisplayDataItem
- An unsupported sink was specified
- At least one of --render_port or --render_output must be…
- buffer_sec must be >= 0, got
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/2d6c6ff44b4969d1.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/transforms/display.py:344
def is_valid(self):
# type: () -> None
""" 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.shortValueView on GitHub (pinned to 12126d8942)