{"record":{"id":"482bd8e31d1a7d93","repo":"apache/beam","slug":"unsupported-type-s-for-value-of-display-data-s","errorCode":null,"errorMessage":"Unsupported type %s for value of display data %s","messagePattern":"Unsupported type (.+?) for value of display data (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/display.py","lineNumber":180,"sourceCode":"        return beam_runner_api_pb2.LabelledPayload(\n            label=label,\n            bool_value=value,\n            key=display_data_dict['key'],\n            namespace=display_data_dict.get('namespace', ''))\n      elif isinstance(value, int):\n        return beam_runner_api_pb2.LabelledPayload(\n            label=label,\n            int_value=value,\n            key=display_data_dict['key'],\n            namespace=display_data_dict.get('namespace', ''))\n      elif isinstance(value, (float, complex)):\n        return beam_runner_api_pb2.LabelledPayload(\n            label=label,\n            double_value=value,  # type: ignore[arg-type]\n            key=display_data_dict['key'],\n            namespace=display_data_dict.get('namespace', ''))\n      else:\n        raise ValueError(\n            'Unsupported type %s for value of display data %s' %\n            (type(value), label))\n\n    dd_protos = []\n    for dd in self.items:\n      if isinstance(dd, beam_runner_api_pb2.DisplayData):\n        dd_protos.append(dd)\n      else:\n        dd_payload = create_payload(dd)\n        if dd_payload:\n          dd_protos.append(\n              beam_runner_api_pb2.DisplayData(\n                  urn=common_urns.StandardDisplayData.DisplayData.LABELLED.urn,\n                  payload=dd_payload.SerializeToString()))\n    return dd_protos\n\n  @classmethod\n  def create_from_options(cls, pipeline_options):","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/display.py#L162-L198","documentation":"Display data values must map to a protobuf LabelledPayload field (str, int, float, bool, timestamp, etc.). When converting DisplayData to its runner API proto, create_payload raises ValueError if the value's Python type has no supported payload representation.","triggerScenarios":"A transform's display_data() returns an item whose value is an arbitrary object (e.g. a custom class instance, dict, or callable) that DisplayDataItem does not classify into a supported type, during to_proto() serialization.","commonSituations":"Adding display_data entries returning custom config objects; refactor leaving a non-primitive in a display item; library upgrades adding display data with new value types.","solutions":["Return a supported primitive (str, int, float, bool) from display_data() for that item.","Convert the object with str(value) or a repr before returning it.","If it's a Beam bug, wrap the value or upgrade to a version where the type is supported."],"exampleFix":"// before\ndef display_data(self):\n    return {'conf': self.my_config_object}\n// after\ndef display_data(self):\n    return {'conf': str(self.my_config_object)}","handlingStrategy":"type-guard","validationCode":"SUPPORTED = (str, int, float, bool)\nfor k, v in self.display_data().items():\n    assert isinstance(v, SUPPORTED), f'display data {k} has unsupported type {type(v)}'","typeGuard":"def is_display_data_value(v) -> bool:\n    return isinstance(v, (str, int, float, bool))","tryCatchPattern":"try:\n    proto = display_data.to_proto()\nexcept ValueError as e:\n    if 'Unsupported type' in str(e):\n        coerce_display_data_items_to_str(display_data)\n        proto = display_data.to_proto()\n    else:\n        raise","preventionTips":["Return only primitives from display_data()","str()-coerce complex objects before returning them","Unit-test to_proto() serialization of custom transforms"],"tags":["apache-beam","python","display-data","serialization"],"backgroundTag":"unsupported-type","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"}