{"record":{"id":"856d58e23638fa27","repo":"apache/beam","slug":"unexpected-keyword-arguments-s","errorCode":null,"errorMessage":"Unexpected keyword arguments: %s","messagePattern":"Unexpected keyword arguments: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/core.py","lineNumber":4104,"sourceCode":"  \"\"\"Merges several PCollections into a single PCollection.\n\n  Copies all elements in 0 or more PCollections into a single output\n  PCollection. If there are no input PCollections, the resulting PCollection\n  will be empty (but see also kwargs below).\n\n  Args:\n    **kwargs: Accepts a single named argument \"pipeline\", which specifies the\n      pipeline that \"owns\" this PTransform. Ordinarily Flatten can obtain this\n      information from one of the input PCollections, but if there are none (or\n      if there's a chance there may be none), this argument is the only way to\n      provide pipeline information and should be considered mandatory.\n  \"\"\"\n  def __init__(self, **kwargs):\n    super().__init__()\n    self.pipeline = kwargs.pop(\n        'pipeline', None)  # type: typing.Optional[Pipeline]\n    if kwargs:\n      raise ValueError('Unexpected keyword arguments: %s' % list(kwargs))\n\n  def _extract_input_pvalues(self, pvalueish):\n    try:\n      pvalueish = tuple(pvalueish)\n    except TypeError:\n      raise ValueError(\n          'Input to Flatten must be an iterable. '\n          'Got a value of type %s instead.' % type(pvalueish))\n\n    # Spot check to see if any of the items are iterables of PCollections\n    # and raise an error if so. This is always a user-error\n    for idx, item in enumerate(pvalueish):\n      if isinstance(item, (list, tuple)) and any(\n          isinstance(sub_item, pvalue.PCollection) for sub_item in item):\n        raise TypeError(\n            'Inputs to Flatten cannot include an iterable of PCollections. '\n            f'(input at index {idx}: \"{item}\")')\n    return pvalueish, pvalueish","sourceCodeStart":4086,"sourceCodeEnd":4122,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/core.py#L4086-L4122","documentation":"Raised by Flatten's __init__ when any keyword argument other than 'pipeline' is passed. Flatten accepts no user-facing configuration besides the optional pipeline argument; unknown kwargs indicate a mistake (e.g. misremembered option names or args meant for another transform).","triggerScenarios":"beam.Flatten(pcolls=[...]), Flatten(parallel_input=True) or any other legacy/imagined kwargs; dynamically forwarding **options into Flatten.","commonSituations":"Porting Spark's union options or old Beam args onto Flatten; passing **kwargs captured from a wrapper function; confusing Flatten with CombineGlobally options.","solutions":["Remove unexpected keyword arguments; Flatten takes PCollections via the pipe operator or a list, not options.","Merge PCollections as: flattened = pcoll1 | pcoll2 | pcoll3 or pc | beam.Flatten(pcoll_list).","Check the API docs for the installed Beam version — the kwargs you pass may belong to a different transform."],"exampleFix":"// before\nresult = (pc1, pc2) | beam.Flatten(pipeline=p)\n// after\nresult = (pc1, pc2) | beam.Flatten()","handlingStrategy":"type-guard","validationCode":"kwargs = {'pipeline': p, 'bogus': 1}\nunknown = set(kwargs) - {'pipeline'}\nassert not unknown, f'unknown Flatten kwargs: {unknown}'","typeGuard":"def is_flatten_kwargs(kw):\n    return all(k == 'pipeline' for k in kw)","tryCatchPattern":"try:\n    merged = (pc1, pc2) | beam.Flatten(**kw)\nexcept ValueError as e:\n    log.error('Flatten kwargs rejected: %s', e)","preventionTips":["Remember Flatten takes no options","Don't forward **kwargs blindly into transforms","Check docs for your Beam version"],"tags":["python","apache-beam","flatten","unexpected-keyword-argument"],"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"}