{"record":{"id":"102b73ec5a3ee6b0","repo":"apache/beam","slug":"element-of-class-does-not-subclass-pipelineoptions","errorCode":null,"errorMessage":"Element of class {}.{} does not subclass PipelineOptions","messagePattern":"Element of class (.+?)\\.(.+?) does not subclass PipelineOptions","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/display.py","lineNumber":218,"sourceCode":"    :class:`~apache_beam.options.pipeline_options.PipelineOptions` instance.\n\n    When creating :class:`~apache_beam.transforms.display.DisplayData`, this\n    method will convert the value of any item of a non-supported type to its\n    string representation.\n    The normal :meth:`.create_from()` method rejects those items.\n\n    Returns:\n      ~apache_beam.transforms.display.DisplayData:\n        A :class:`~apache_beam.transforms.display.DisplayData` instance with\n        populated items.\n\n    Raises:\n      ValueError: If the **has_display_data** argument is\n        not an instance of :class:`HasDisplayData`.\n    \"\"\"\n    from apache_beam.options.pipeline_options import PipelineOptions\n    if not isinstance(pipeline_options, PipelineOptions):\n      raise ValueError(\n          'Element of class {}.{} does not subclass PipelineOptions'.format(\n              pipeline_options.__module__, pipeline_options.__class__.__name__))\n\n    items = {\n        k: (v if DisplayDataItem._get_value_type(v) is not None else str(v))\n        for k, v in pipeline_options.display_data().items()\n    }\n    return cls(pipeline_options._get_display_data_namespace(), items)\n\n  @classmethod\n  def create_from(cls, has_display_data, extra_items=None):\n    \"\"\" Creates :class:`~apache_beam.transforms.display.DisplayData` from a\n    :class:`HasDisplayData` instance.\n\n    Returns:\n      ~apache_beam.transforms.display.DisplayData:\n        A :class:`~apache_beam.transforms.display.DisplayData` instance with\n        populated items.","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/display.py#L200-L236","documentation":"DisplayData.create_from_options requires its argument to be an instance of PipelineOptions. It raises ValueError when an object of another class is passed, naming the offending module and class in the message.","triggerScenarios":"Calling DisplayData.create_from_options(opts) where opts is a plain dict, a custom config class, or a PipelineOptions subclass instance but the function receives the class itself (not an instance).","commonSituations":"Passing the PipelineOptions class instead of an instance; passing raw dict-based options from custom runner code; mixing up create_from_options and create_from.","solutions":["Construct PipelineOptions first: DisplayData.create_from_options(PipelineOptions(argv)).","Ensure the object passed is an instance of a PipelineOptions subclass, not the class object.","If the object is a HasDisplayData (e.g. a DoFn/transform), call DisplayData.create_from() instead."],"exampleFix":"// before\ndd = DisplayData.create_from_options(PipelineOptions)\n// after\ndd = DisplayData.create_from_options(PipelineOptions(['--runner=DirectRunner']))","handlingStrategy":"type-guard","validationCode":"from apache_beam.options.pipeline_options import PipelineOptions\nassert isinstance(opts, PipelineOptions), 'create_from_options needs a PipelineOptions instance'","typeGuard":"def is_pipeline_options(o) -> bool:\n    from apache_beam.options.pipeline_options import PipelineOptions\n    return isinstance(o, PipelineOptions)","tryCatchPattern":"try:\n    dd = DisplayData.create_from_options(opts)\nexcept ValueError as e:\n    if 'does not subclass PipelineOptions' in str(e):\n        dd = DisplayData.create_from_options(PipelineOptions([]))\n    else:\n        raise","preventionTips":["Instantiate PipelineOptions before passing it","Use create_from for HasDisplayData objects and create_from_options for options","Check argument types in runner/tooling wrappers"],"tags":["apache-beam","python","display-data","pipeline-options"],"backgroundTag":"invalid-argument-value","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"}