{"record":{"id":"0e0fa03e784a8200","repo":"apache/beam","slug":"invalid-displaydataitem-value-is-of-an-unsupported-type","errorCode":null,"errorMessage":"Invalid DisplayDataItem. Value {} is of an unsupported type.","messagePattern":"Invalid DisplayDataItem\\. Value (.+?) is of an unsupported type\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/display.py","lineNumber":347,"sourceCode":"    \"\"\" Checks that all the necessary fields of the :class:`DisplayDataItem`\n    are filled in. It checks that neither key, namespace, value or type are\n    :data:`None`.\n\n    Raises:\n      ValueError: If the item does not have a key, namespace,\n        value or type.\n    \"\"\"\n    if self.key is None:\n      raise ValueError(\n          'Invalid DisplayDataItem %s. Key must not be None.' % self)\n    if self.namespace is None:\n      raise ValueError(\n          'Invalid DisplayDataItem %s. Namespace must not be None' % self)\n    if self.value is None:\n      raise ValueError(\n          'Invalid DisplayDataItem %s. Value must not be None' % self)\n    if self.type is None:\n      raise ValueError(\n          'Invalid DisplayDataItem. Value {} is of an unsupported type.'.format(\n              self.value))\n\n  def _get_dict(self):\n    res = {\n        'key': self.key,\n        'namespace': self.namespace,\n        'type': self.type if self.type != 'CLASS' else 'STRING'\n    }\n    # TODO: Python Class types should not be special-cased once\n    # the Fn API is in.\n    if self.url is not None:\n      res['url'] = self.url\n    if self.shortValue is not None:\n      res['shortValue'] = self.shortValue\n    if self.label is not None:\n      res['label'] = self.label\n    res['value'] = self._format_value(self.value, self.type)","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/display.py#L329-L365","documentation":"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.","triggerScenarios":"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()).","commonSituations":"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.","solutions":["Pass a supported primitive: convert the value with str(), int(), float(), or bool before creating the DisplayDataItem","If the value is optional, skip emitting the item instead of building one with an unsupported value (also note value must not be None)","Check that you are not overriding 'type' accidentally by passing an unsupported keyword"],"exampleFix":"// before\nyield DisplayDataItem(my_custom_obj, label='cfg')\n// after\nyield DisplayDataItem(str(my_custom_obj), label='cfg')","handlingStrategy":"validation","validationCode":"def ensure_displayable(v):\n    if v is None or not isinstance(v, (str, int, float, bool)):\n        raise TypeError(f'Non-displayable value {v!r}; coerce to str/int/float/bool')\n    return v","typeGuard":"def is_display_data_type(v) -> bool:\n    return isinstance(v, (str, int, float, bool))","tryCatchPattern":"try:\n    d = item.get_dict()\nexcept ValueError as e:\n    logger.warning('dropping display data: %s', e)\n    d = None","preventionTips":["Only pass JSON-like primitives into display_data()","Coerce custom objects with str() or repr()","Never emit a DisplayDataItem for absent values — skip it instead"],"tags":["apache-beam","display-data","validation"],"backgroundTag":"schema-validation-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}