{"record":{"id":"555c556465737c8a","repo":"apache/beam","slug":"parameter-options-if-specified-must-be-of-type","errorCode":null,"errorMessage":"Parameter options, if specified, must be of type PipelineOptions. Received : %r","messagePattern":"Parameter options, if specified, must be of type PipelineOptions\\. Received : %r","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/pipeline.py","lineNumber":181,"sourceCode":"      ValueError: if either the runner or options argument is not\n        of the expected type.\n    \"\"\"\n    # Initializing logging configuration in case the user did not set it up.\n    logging.basicConfig()\n\n    if options is not None:\n      if isinstance(options, PipelineOptions):\n        # Make a deep copy of options since they could be overwritten in later\n        # steps. However, the 'runner' object within 'options' is excluded from\n        # the deep copy (it is shallow copied) due to potential issues with deep\n        # copying specific runner instances, such as FlumeRunner.\n        saved_runner = options.view_as(StandardOptions).runner\n        options.view_as(StandardOptions).runner = None\n        self._options = copy.deepcopy(options)\n        self._options.view_as(StandardOptions).runner = saved_runner\n        options.view_as(StandardOptions).runner = saved_runner\n      else:\n        raise ValueError(\n            'Parameter options, if specified, must be of type PipelineOptions. '\n            'Received : %r' % options)\n    elif argv is not None:\n      if isinstance(argv, list):\n        self._options = PipelineOptions(argv)\n      else:\n        raise ValueError(\n            'Parameter argv, if specified, must be a list. Received : %r' %\n            argv)\n    else:\n      self._options = PipelineOptions([])\n\n    FileSystems.set_options(self._options)\n\n    if runner is None:\n      runner = self._options.view_as(StandardOptions).runner\n      if runner is None:\n        runner = StandardOptions.DEFAULT_RUNNER","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/pipeline.py#L163-L199","documentation":"Pipeline.__init__ accepts either a PipelineOptions instance (or None) via options=, or an argv list. If options is given but is not a PipelineOptions (e.g. a dict or string), ValueError is raised. This prevents silently misusing the two parameter styles.","triggerScenarios":"Pipeline(runner, options={'project': 'p'}) or Pipeline(options='--project=p') — passing a dict/string where only PipelineOptions is allowed.","commonSituations":"Migrating code that previously passed a dict of flags, or passing the same string you'd give at the command line.","solutions":["Pass a PipelineOptions instance: Pipeline(options=PipelineOptions([...])).","Pass flags as the argv list instead: Pipeline(argv=['--project=p']).","Convert a dict of flags to PipelineOptions by building flag strings."],"exampleFix":"# before\np = Pipeline(options=['--runner=DirectRunner'])\n# after\nfrom apache_beam.options.pipeline_options import PipelineOptions\np = Pipeline(options=PipelineOptions(['--runner=DirectRunner']))","handlingStrategy":"type-guard","validationCode":"if options is not None and not isinstance(options, PipelineOptions): options = PipelineOptions([f'--{k}={v}' for k, v in options.items()])","typeGuard":"def is_pipeline_options(v) -> bool:\n    return v is None or isinstance(v, PipelineOptions)","tryCatchPattern":"try:\n    p = Pipeline(options=options)\nexcept ValueError as e:\n    raise TypeError('options must be PipelineOptions or None; use argv for flags') from e","preventionTips":["Only pass PipelineOptions instances (or None) to the options= parameter.","Pass raw flags through argv instead of options.","Enable type checking (mypy/pyright) to catch wrong types early."],"tags":["apache-beam","python","type-error"],"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"}