{"record":{"id":"da86f061fffa5702","repo":"apache/beam","slug":"s-got-multiple-values-for-argument-s","errorCode":null,"errorMessage":"%s() got multiple values for argument '%s'","messagePattern":"(.+?)\\(\\) got multiple values for argument '(.+?)'","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/frame_base.py","lineNumber":521,"sourceCode":"    base_arg_names = base_arg_spec.args\n    # Some arguments are keyword only and we still want to check against those.\n    all_possible_base_arg_names = base_arg_names + base_arg_spec.kwonlyargs\n    beam_arg_names = getfullargspec(func).args\n\n    if not_found := (set(beam_arg_names) - set(all_possible_base_arg_names) -\n                     set(removed_arg_names)):\n      raise TypeError(\n          f\"Beam definition of {func.__name__} has arguments that are not found\"\n          f\" in the base version of the function: {not_found}\")\n\n    @functools.wraps(func)\n    def wrapper(*args, **kwargs):\n      if len(args) > len(base_arg_names):\n        raise TypeError(f\"{func.__name__} got too many positioned arguments.\")\n\n      for name, value in zip(base_arg_names, args):\n        if name in kwargs:\n          raise TypeError(\n              \"%s() got multiple values for argument '%s'\" %\n              (func.__name__, name))\n        kwargs[name] = value\n      # Still have to populate these for the Beam function signature.\n      if removed_args:\n        for name in removed_args:\n          if name not in kwargs:\n            kwargs[name] = None\n      return func(**kwargs)\n\n    return wrapper\n\n  return wrap\n\n\nBEAM_SPECIFIC = \"Differences from pandas\"\n\nSECTION_ORDER = [","sourceCodeStart":503,"sourceCodeEnd":539,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/frame_base.py#L503-L539","documentation":"The same signature-adapting wrapper zips positional args against base_arg_names and raises this standard-Python-style TypeError when a positional argument's name also appears in kwargs — i.e. the argument was supplied twice (once positionally, once by keyword). This prevents ambiguous duplicate bindings before invoking the Beam implementation.","triggerScenarios":"Calling a dataframe method where the same parameter is passed both positionally and by keyword, e.g. df.quantile(0.5, q=0.5) or df.rolling(2, window=2) style collisions; also triggered by helpers that forward **kwargs after adding positional args.","commonSituations":"Refactored call sites that added a keyword arg without removing the positional one; generic wrapper code spreading kwargs over functions with positional defaults; dynamic argument construction from config where a key duplicates a positional slot.","solutions":["Remove the duplicate keyword argument, keeping either the positional or keyword form.","Build kwargs programmatically and assert no key collides with the positional names before calling.","Update the call to match the pandas signature (positional args fill base_arg_names in order)."],"exampleFix":"// before\ndf.quantile(0.5, q=0.5)\n// after\ndf.quantile(0.5)","handlingStrategy":"validation","validationCode":"import inspect\nparams = set(inspect.signature(func).parameters)\npositional = set(inspect.signature(func).parameters)[:len(args)]\ndupes = positional & kwargs.keys()\nassert not dupes, f'duplicate argument: {dupes}'","typeGuard":"def has_duplicate_binding(args, kwargs, func) -> bool:\n    import inspect\n    names = list(inspect.signature(func).parameters)[:len(args)]\n    return bool(set(names) & set(kwargs))","tryCatchPattern":"try:\n    df.quantile(0.5, q=0.5)\nexcept TypeError as e:\n    if 'multiple values for argument' in str(e):\n        df.quantile(0.5)\n    else:\n        raise","preventionTips":["When refactoring calls, remove the positional arg when adding its keyword form.","Build kwargs from config programmatically and check for collisions with positional slots.","Prefer all-keyword calling style for dataframe methods to eliminate duplication."],"tags":["python","apache-beam","dataframe-api","duplicate-argument"],"backgroundTag":"invalid-argument","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"}