apache/beam · error · ValueError

No fallback.

Error message

No fallback.

What it means

FastPrimitivesCoderImpl tries each of its specialized coder impls; when none can encode the value it falls back to writing byte 0xFF and delegating to _fallback_coder_impl. If no fallback coder was configured, Beam raises ValueError('No fallback.') because the value cannot be encoded by any available coder.

Source

Thrown at sdks/python/apache_beam/coders/coder_impl.py:1578


class _OrderedUnionCoderImpl(StreamCoderImpl):
  def __init__(self, coder_impl_types, fallback_coder_impl):
    assert len(coder_impl_types) < 128
    self._types, self._coder_impls = zip(*coder_impl_types)
    self._fallback_coder_impl = fallback_coder_impl

  def encode_to_stream(self, value, out, nested):
    value_t = type(value)
    for (ix, t) in enumerate(self._types):
      if value_t is t:
        out.write_byte(ix)
        c = self._coder_impls[ix]  # for typing
        c.encode_to_stream(value, out, nested)
        break
    else:
      if self._fallback_coder_impl is None:
        raise ValueError("No fallback.")
      out.write_byte(0xFF)
      self._fallback_coder_impl.encode_to_stream(value, out, nested)

  def decode_from_stream(self, in_stream, nested):
    ix = in_stream.read_byte()
    if ix == 0xFF:
      if self._fallback_coder_impl is None:
        raise ValueError("No fallback.")
      return self._fallback_coder_impl.decode_from_stream(in_stream, nested)
    else:
      c = self._coder_impls[ix]  # for typing
      return c.decode_from_stream(in_stream, nested)


class WindowedValueCoderImpl(StreamCoderImpl):
  """For internal use only; no backwards-compatibility guarantees.

  A coder for windowed values."""

View on GitHub (pinned to 12126d8942)

Solutions

  1. Provide a fallback coder impl (e.g., a pickling or ProtoCoder-based impl) when constructing the fast-primitives coder
  2. Ensure the values being encoded are the primitives the fast coder supports (bytes, str, int, float, bool, etc.)
  3. Use a regular coder (e.g., PickleCoder) for non-primitive values instead of the fast-primitives coder
  4. Locate the transform emitting non-primitive elements and coerce its output to supported primitives

Example fix

// before
impl = FastPrimitivesCoderImpl(fallback_coder_impl=None)
impl.encode_to_stream(MyCustomClass(), out, False)  # ValueError: No fallback.
// after
impl = FastPrimitivesCoderImpl(
    fallback_coder_impl=PickleCoder().get_impl())
impl.encode_to_stream(MyCustomClass(), out, False)  # encoded via fallback
Defensive patterns

Strategy: validation

Validate before calling

PRIMITIVES = (bytes, str, int, float, bool, type(None))
assert isinstance(value, PRIMITIVES) or fallback_coder_impl is not None, \
    f'non-primitive {type(value)} requires a fallback coder'

Type guard

def encodable_without_fallback(v: object) -> bool:
    return isinstance(v, (bytes, str, int, float, bool, type(None)))

Try / catch

try:
    impl.encode_to_stream(value, out, nested)
except ValueError as e:
    if str(e) == 'No fallback.':
        PickleCoder().get_impl().encode_to_stream(value, out, nested)
    else:
        raise

Prevention

When it happens

Trigger: Encoding a value that none of the fast primitive coder impls accept (not a supported primitive/bytes etc.) with a FastPrimitivesCoderImpl constructed without a fallback coder impl (fallback is None).

Common situations: Directly constructing the fast-primitives coder without a fallback and then sending non-primitive objects (custom classes, complex types); internal pipelines assuming primitives only but a transform emits a richer type.

Understand the failure class

Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.

Related errors


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