{"record":{"id":"95376e46d2488fb1","repo":"apache/beam","slug":"unexpected-dofn-type-s","errorCode":null,"errorMessage":"Unexpected DoFn type: %s","messagePattern":"Unexpected DoFn type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/core.py","lineNumber":2021,"sourceCode":"\n    return wrapper\n\n  @classmethod\n  def create(cls, fn, args, kwargs):\n    if hasattr(fn, '_stateless_dofn_urn'):\n      assert not args and not kwargs\n      return StatelessDoFnInfo(fn._stateless_dofn_urn)\n    else:\n      return PickledDoFnInfo(cls._pickled_do_fn_info(fn, args, kwargs))\n\n  @staticmethod\n  def from_runner_api(spec, unused_context):\n    if spec.urn == python_urns.PICKLED_DOFN_INFO:\n      return PickledDoFnInfo(spec.payload)\n    elif spec.urn in StatelessDoFnInfo.REGISTERED_DOFNS:\n      return StatelessDoFnInfo(spec.urn)\n    else:\n      raise ValueError('Unexpected DoFn type: %s' % spec.urn)\n\n  @staticmethod\n  def _pickled_do_fn_info(fn, args, kwargs):\n    # This can be cleaned up once all runners move to portability.\n    return pickler.dumps((fn, args, kwargs, None, None))\n\n  def serialized_dofn_data(self):\n    raise NotImplementedError(type(self))\n\n\nclass PickledDoFnInfo(DoFnInfo):\n  def __init__(self, serialized_data):\n    self._serialized_data = serialized_data\n\n  def serialized_dofn_data(self):\n    return self._serialized_data\n\n  def to_runner_api(self, unused_context):","sourceCodeStart":2003,"sourceCodeEnd":2039,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/core.py#L2003-L2039","documentation":"DoFnInfo.from_runner_api deserializes a DoFnInfo protobuf by dispatching on its URN. Only the pickled-info URN and URNs registered in StatelessDoFnInfo.REGISTERED_DOFNS are recognized; any other URN means the payload references a DoFn type this Beam version cannot interpret, so it raises ValueError.","triggerScenarios":"Deserializing a pipeline/runner-api proto whose DoFn spec.urn is not PICKLED_DOFN_INFO and not in REGISTERED_DOFNS — typically a pipeline produced by a different (newer or older) Beam version or a custom URN.","commonSituations":"Cross-version pipeline transport (submitting a pipeline generated by Beam X to a Beam Y SDK worker); custom transforms writing their own DoFn URNs; stale worker images during pipeline upgrade.","solutions":["Align Beam versions: run the pipeline with the same (or compatible) apache_beam version that serialized the DoFnInfo.","If the DoFn is a recognized stateless built-in, ensure the SDK host includes it (upgrade apache_beam so the URN is in REGISTERED_DOFNS).","Re-generate the pipeline with the target SDK instead of hand-carrying runner-api protos across versions.","Check for stale prebuilt worker containers/images and rebuild them with the current SDK."],"exampleFix":"null","handlingStrategy":"fallback","validationCode":"from apache_beam.transforms.core import StatelessDoFnInfo, DoFnInfo\nfrom apache_beam.portability import python_urns\nassert spec.urn == python_urns.PICKLED_DOFN_INFO or spec.urn in StatelessDoFnInfo.REGISTERED_DOFNS, 'unsupported DoFn urn: %s' % spec.urn","typeGuard":"def is_supported_dofn_urn(urn, registered):\n    return urn == python_urns.PICKLED_DOFN_INFO or urn in registered","tryCatchPattern":"try:\n    info = DoFnInfo.from_runner_api(spec, context)\nexcept ValueError as e:\n    logger.error('DoFn urn %s unsupported by SDK %s; align Beam versions', spec.urn, beam.__version__)\n    raise","preventionTips":["Use the same apache_beam version across pipeline construction and workers.","Rebuild worker images after SDK upgrades.","Avoid hand-crafted DoFn URNs in custom runner-api protos."],"tags":["python","apache-beam","deserialization","urn"],"backgroundTag":"unsupported-operation","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"}