{"record":{"id":"3fb95e08201157ed","repo":"apache/beam","slug":"invalid-displaydataitem-s-namespace-must-not-be-none","errorCode":null,"errorMessage":"Invalid DisplayDataItem %s. Namespace must not be None","messagePattern":"Invalid DisplayDataItem (.+?)\\. Namespace must not be None","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/display.py","lineNumber":341,"sourceCode":"      return True\n    return False\n\n  def is_valid(self):\n    # type: () -> None\n\n    \"\"\" 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:","sourceCodeStart":323,"sourceCodeEnd":359,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/display.py#L323-L359","documentation":"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.","triggerScenarios":"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().","commonSituations":"Manually built DisplayDataItem objects missing namespace; copying items between DisplayData objects; deserialization paths that dropped the namespace.","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."],"exampleFix":"// before\nitem = DisplayDataItem(key='k', value=1)\n// after\nitem = DisplayDataItem(key='k', value=1, namespace='my.module.MyDoFn')","handlingStrategy":"validation","validationCode":"for item in display_data.items:\n    if getattr(item, 'namespace', None) is None:\n        raise ValueError('display data item missing namespace')","typeGuard":"def item_has_namespace(item) -> bool:\n    return getattr(item, 'namespace', None) is not None","tryCatchPattern":"try:\n    d = display_data.get_dict()\nexcept ValueError as e:\n    if 'Namespace must not be None' in str(e):\n        rebuild_display_data_from_source(display_data)\n        d = display_data.get_dict()\n    else:\n        raise","preventionTips":["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"],"tags":["apache-beam","python","display-data","validation"],"backgroundTag":"empty-required-field","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"}