{"record":{"id":"4c43d863513606e7","repo":"apache/beam","slug":"parameter-argv-if-specified-must-be-a-list-received-r","errorCode":null,"errorMessage":"Parameter argv, if specified, must be a list. Received : %r","messagePattern":"Parameter argv, if specified, must be a list\\. Received : %r","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/pipeline.py","lineNumber":188,"sourceCode":"      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\n        logging.info((\n            'Missing pipeline option (runner). Executing pipeline '\n            'using the default runner: %s.'),\n                     runner)\n\n    if isinstance(runner, str):\n      runner = create_runner(runner)","sourceCodeStart":170,"sourceCodeEnd":206,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/pipeline.py#L170-L206","documentation":"Pipeline.__init__ validates the argv/options parameter: when it is not a PipelineOptions instance it must be a list of command-line argument strings (e.g. sys.argv[1:]) so it can be parsed; the received object is neither.","triggerScenarios":"Pipeline(runner, argv='--project=my-project') — passing a single flag string instead of a list, or passing a dict as argv.","commonSituations":"Passing sys.argv (list, fine) vs a hand-written flag string, or copying examples that pass a string literal of flags.","solutions":["Wrap flags in a list: argv=['--project=my-project'].","Split a string with shlex.split before passing as argv.","Alternatively pass PipelineOptions(shlex.split(flags_str)) via options=."],"exampleFix":"# before\np = Pipeline(argv='--project=my-project --runner=DirectRunner')\n# after\nimport shlex\np = Pipeline(argv=shlex.split('--project=my-project --runner=DirectRunner'))","handlingStrategy":"type-guard","validationCode":"if isinstance(argv, str): argv = shlex.split(argv)","typeGuard":"def is_argv_list(v) -> bool:\n    return v is None or (isinstance(v, list) and all(isinstance(x, str) for x in v))","tryCatchPattern":"try:\n    p = Pipeline(argv=argv)\nexcept ValueError as e:\n    p = Pipeline(argv=shlex.split(argv))","preventionTips":["Always pass argv as a list of strings.","Split any flag string with shlex.split before passing.","Add a small helper that normalizes argv input."],"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"}