{"record":{"id":"4f00ecea657f1a63","repo":"apache/beam","slug":"dofn-process-method-only-parameter-s-cannot-be-used-in-s","errorCode":null,"errorMessage":"DoFn.process() method-only parameter %s cannot be used in %s.","messagePattern":"DoFn\\.process\\(\\) method-only parameter (.+?) cannot be used in (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/runners/common.py","lineNumber":383,"sourceCode":"        raise NotImplementedError(\n            f\"DoFn {self.do_fn!r} has unsupported per-key DoFn param {d}. \"\n            \"Per-key DoFn params are not yet supported for process_batch \"\n            \"(https://github.com/apache/beam/issues/21653).\")\n\n      # Fallback to catch anything not explicitly supported\n      if not d in (core.DoFn.WindowParam,\n                   core.DoFn.TimestampParam,\n                   core.DoFn.PaneInfoParam):\n        raise ValueError(\n            f\"DoFn {self.do_fn!r} has unsupported process_batch \"\n            f\"method parameter {d}\")\n\n  def _validate_bundle_method(self, method_wrapper):\n    \"\"\"Validate that none of the DoFnParameters are used in the function\n    \"\"\"\n    for param in core.DoFn.DoFnProcessParams:\n      if param in method_wrapper.defaults:\n        raise ValueError(\n            'DoFn.process() method-only parameter %s cannot be used in %s.' %\n            (param, method_wrapper))\n\n  def _validate_stateful_dofn(self):\n    # type: () -> None\n    userstate.validate_stateful_dofn(self.do_fn)\n\n  def is_splittable_dofn(self):\n    # type: () -> bool\n    return self.get_restriction_provider() is not None\n\n  def get_restriction_coder(self):\n    # type: () -> Optional[TupleCoder]\n\n    \"\"\"Get coder for a restriction when processing an SDF. \"\"\"\n    if self.is_splittable_dofn():\n      return TupleCoder([\n          (self.get_restriction_provider().restriction_coder()),","sourceCodeStart":365,"sourceCodeEnd":401,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/runners/common.py#L365-L401","documentation":"_validate_bundle_method ensures DoFnProcessParams (process-only special parameters like SideInputParam, StateParam, TimerParam, etc.) are not used on non-process methods (start_bundle/finish_bundle/bundle methods). Using them there is meaningless, so ValueError names the offending parameter and method.","triggerScenarios":"def finish_bundle(self, si=DoFn.SideInputParam) or adding DoFnProcessParams defaults to start_bundle/finish_bundle; validation via _validate at DoFnSignature creation.","commonSituations":"Copy-pasting the process() signature into finish_bundle; assuming start_bundle can access side inputs or state like process does.","solutions":["Remove the process-only parameter from the bundle method","Access state via self.state_handler / explicit APIs if the DoFn is stateful, per Beam's documented patterns","Move logic needing those parameters into process()"],"exampleFix":"// before\ndef finish_bundle(self, si=DoFn.SideInputParam): ...\n// after\ndef finish_bundle(self): ...","handlingStrategy":"validation","validationCode":"from apache_beam.transforms.core import DoFn\nfor m in ('start_bundle', 'finish_bundle'):\n    d = getattr(MyDoFn, m, None)\n    if d:\n        assert not any(p in (d.__defaults__ or []) for p in DoFn.DoFnProcessParams), m","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep bundle methods parameterless (besides self)","Never copy process() special params into start/finish_bundle"],"tags":["python","apache-beam","dofn"],"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-14T16:17:12.679Z"}