apache/beam · error · TypeCheckError

Transform "{full_label}" was applied to the output of an obj

Error message

Transform "{full_label}" was applied to the output of an object of type None.

What it means

During _apply_internal, if the pvalueish input is None, Beam raises TypeCheckError stating the transform (by full label) was applied to the output of an object of type None. Transforms must consume PValue-derived inputs, and None indicates the previous step produced no value (often a failed/chained apply).

Source

Thrown at sdks/python/apache_beam/pipeline.py:770

            'updating a pipeline or reloading the job state. '
            'This is not recommended for streaming jobs.')
        unique_label = self._generate_unique_label(transform)
        return self.apply(transform, pvalueish, unique_label)
      else:
        raise RuntimeError(
            'A transform with label "%s" already exists in the pipeline. '
            'To apply a transform with a specified label, write '
            'pvalue | "label" >> transform or use the option '
            '"auto_unique_labels" to automatically generate unique '
            'transform labels. Note "auto_unique_labels" '
            'could cause data loss when updating a pipeline or '
            'reloading the job state. This is not recommended for '
            'streaming jobs.' % full_label)
    self.applied_labels.add(full_label)

    if pvalueish is None:
      full_label = self._current_transform().full_label
      raise TypeCheckError(
          f'Transform "{full_label}" was applied to the output of '
          f'an object of type None.')

    pvalueish, inputs = transform._extract_input_pvalues(pvalueish)
    try:
      if not isinstance(inputs, dict):
        inputs = {str(ix): input for (ix, input) in enumerate(inputs)}
    except TypeError:
      raise NotImplementedError(
          'Unable to extract PValue inputs from %s; either %s does not accept '
          'inputs of this format, or it does not properly override '
          '_extract_input_pvalues' % (pvalueish, transform))
    for t, leaf_input in inputs.items():
      if not isinstance(leaf_input, pvalue.PValue) or not isinstance(t, str):
        raise NotImplementedError(
            '%s does not properly override _extract_input_pvalues, '
            'returned %s from %s' % (transform, inputs, pvalueish))

View on GitHub (pinned to 12126d8942)

Solutions

  1. Inspect the expression producing the input; it returned None — fix the producer to return a PCollection.
  2. Check pipeline.apply argument order: apply(transform, pvalueish, label).
  3. Ensure your helper/composite transform's expand() returns the resulting PCollection.
  4. Verify each `|` chain starts from a Pipeline/PBegin/PCollection, not the result of an in-place operation.

Example fix

// before
def build(p):
  p | 'step' >> beam.Map(str)  # returns None
out = build(pipeline) | beam.Map(len)
// after
def build(p):
  return p | 'step' >> beam.Map(str)
out = build(pipeline) | beam.Map(len)
Defensive patterns

Strategy: type-guard

Validate before calling

from apache_beam.pvalue import PValue
assert input_pvalue is not None and isinstance(input_pvalue, PValue), 'transform input is None'

Type guard

from apache_beam.pvalue import PValue
def is_pvalue_input(x) -> bool:
    return isinstance(x, PValue)

Try / catch

try:
    result = transform_applier.apply(ptransform, pvalueish)
except TypeCheckError as e:
    if 'object of type None' in str(e):
        raise ValueError('upstream step returned None; check its return value') from e

Prevention

When it happens

Trigger: Chaining like pipeline | beam.Map(...) where the left side returned None; assigning result = some_operation that returns None and then passing it to a transform; calling a transform on a function that forgot to return a PCollection.

Common situations: Misordered arguments to pipeline.apply (label/pvalueish swapped so pvalueish ends up None); helper functions that build pipelines but return nothing; PTransforms whose expand doesn't return the output.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/7a431eadad66531c. Report an issue: GitHub.