{"record":{"id":"59609712dcbedca0","repo":"apache/beam","slug":"proxy-proxy-has-unsupported-type-type-proxy","errorCode":null,"errorMessage":"Proxy '{proxy}' has unsupported type '{type(proxy)}'","messagePattern":"Proxy '(.+?)' has unsupported type '(.+?)'","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/dataframe/convert.py","lineNumber":129,"sourceCode":"    label += \" with indexes\"\n\n  if label not in UNBATCHED_CACHE:\n    proxy = expr.proxy()\n    shim_dofn: beam.DoFn\n    if isinstance(proxy, pd.DataFrame):\n      shim_dofn = DataFrameToRowsFn(proxy, include_indexes)\n    elif isinstance(proxy, pd.Series):\n      if include_indexes:\n        warnings.warn(\n            \"Pipeline is converting a DeferredSeries to PCollection \"\n            \"with include_indexes=True. Note that this parameter is \"\n            \"_not_ respected for DeferredSeries conversion. To \"\n            \"include the index with your data, produce a\"\n            \"DeferredDataFrame instead.\")\n\n      shim_dofn = SeriesToElementsFn(proxy)\n    else:\n      raise TypeError(f\"Proxy '{proxy}' has unsupported type '{type(proxy)}'\")\n\n    UNBATCHED_CACHE[label] = pc | label >> beam.ParDo(shim_dofn)\n\n  # Note unbatched cache is keyed by the expression id as well as parameters\n  # for the unbatching (i.e. include_indexes)\n  return UNBATCHED_CACHE[label]\n\n\nclass DataFrameToRowsFn(beam.DoFn):\n  def __init__(self, proxy, include_indexes):\n    self._proxy = proxy\n    self._include_indexes = include_indexes\n\n  @beam.DoFn.yields_batches\n  def process(self, element: pd.DataFrame) -> Iterable[pd.DataFrame]:\n    yield element\n\n  def infer_output_type(self, input_element_type):","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/dataframe/convert.py#L111-L147","documentation":"During unbatching (to_pcollection of deferred dataframes back to elements, via maybe_unbatch/_make_unbatched_pcoll), the proxy object must be a DeferredDataFrame or DeferredSeries. Any other proxy type (e.g. a plain pandas DataFrame or another wrapper) is unsupported and raises TypeError.","triggerScenarios":"Passing proxy= to convert.to_dataframe/to_pcollection with a raw pd.DataFrame/pd.Series instead of its deferred counterpart, or a proxy of an unrelated type; mixing plain pandas objects into the dataframe-on-Beam API.","commonSituations":"Users caching a plain pandas placeholder from outside the deferred session; upgraded code paths where a proxy constructed earlier as concrete pandas is reused; custom integrations building their own proxies.","solutions":["Pass a DeferredDataFrame/DeferredSeries proxy — get it via expressions.PlaceholderExpression + frame_base.DeferredFrame.wrap, or omit proxy and ensure the PCollection has a schema.","If you have a plain pd.DataFrame, wrap it: frame_base.DeferredFrame.wrap(expressions.PlaceholderExpression(df.iloc[:0], ...)).","Check the proxy's type before calling and normalize it to DeferredBase.","Avoid passing concrete pandas objects; they are only accepted for to_pcollection's non-deferred inputs, not as proxies."],"exampleFix":"// before\ndf = convert.to_dataframe(pcoll, proxy=pd.DataFrame(columns=['a', 'b']))\n// after\nproxy = frame_base.DeferredFrame.wrap(\n    expressions.PlaceholderExpression(pd.DataFrame(columns=['a', 'b'])))\ndf = convert.to_dataframe(pcoll, proxy=proxy)","handlingStrategy":"type-guard","validationCode":"from apache_beam.dataframe import frame_base\nif proxy is not None and not isinstance(proxy, frame_base.DeferredBase):\n    raise TypeError('proxy must be a DeferredDataFrame/DeferredSeries')","typeGuard":"def is_deferred_frame(obj) -> bool:\n    from apache_beam.dataframe import frame_base\n    return isinstance(obj, frame_base.DeferredBase)","tryCatchPattern":"try:\n    out = convert.to_pcollection(df, proxy=proxy)\nexcept TypeError as e:\n    if 'unsupported type' in str(e):\n        out = convert.to_pcollection(df, proxy=wrap_as_deferred(proxy))\n    else:\n        raise","preventionTips":["Never pass concrete pandas objects as proxies.","Wrap placeholders with DeferredFrame.wrap when constructing proxies manually.","Omit proxy and rely on schema-typed PCollections where possible.","Assert isinstance(proxy, DeferredBase) before calls in helper code."],"tags":["python","pandas","dataframe","type-error"],"backgroundTag":"incompatible-source-type","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"}