apache/beam · error · ValueError
Invalid DisplayDataItem
Error message
Invalid DisplayDataItem %s. Namespace must not be None
What it means
DisplayDataItem.is_valid requires a namespace identifying which component the item belongs to; it raises ValueError when namespace is None. The namespace is usually derived automatically from the owning class.
Solutions
- Create items through DisplayData.create_from()/create_from_options() so the namespace is auto-populated.
- Set the namespace explicitly when constructing the item manually.
- Inspect the item in the error message to find where namespace was lost.
Example fix
// before item = DisplayDataItem(key='k', value=1) // after item = DisplayDataItem(key='k', value=1, namespace='my.module.MyDoFn')
Defensive patterns
Strategy: validation
Validate before calling
for item in display_data.items:
if getattr(item, 'namespace', None) is None:
raise ValueError('display data item missing namespace') Type guard
def item_has_namespace(item) -> bool:
return getattr(item, 'namespace', None) is not None Try / catch
try:
d = display_data.get_dict()
except ValueError as e:
if 'Namespace must not be None' in str(e):
rebuild_display_data_from_source(display_data)
d = display_data.get_dict()
else:
raise Prevention
- Always derive items from a DisplayData object that knows its owner
- Do not manually copy DisplayDataItem objects across namespaces
- Validate serialized display data in integration tests
When it happens
Trigger: Serializing a DisplayDataItem whose namespace field was never populated (e.g. an item constructed manually or detached from its DisplayData origin) via is_valid()/get_dict().
Common situations: Manually built DisplayDataItem objects missing namespace; copying items between DisplayData objects; deserialization paths that dropped the namespace.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
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/3fb95e08201157ed.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/python/apache_beam/transforms/display.py:341
return True
return False
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:View on GitHub (pinned to 12126d8942)