apache/beam · error · NotImplementedError
Invalid PaneInfoEncoding: %s
Error message
Invalid PaneInfoEncoding: %s
What it means
When encoding a windowed_value.PaneInfo, _PaneInfoCoderImpl picks a PaneInfoEncoding based on which index fields are set (NONE, ONE_INDEX, TWO_INDICES). Any encoding_type outside the known enum has no byte-level representation, so Beam raises NotImplementedError while writing the pane info. This indicates an unrecognized/invalid PaneInfoEncoding value rather than corrupt data.
Source
Thrown at sdks/python/apache_beam/coders/coder_impl.py:1524
value._timing == windowed_value.PaneInfoTiming.EARLY):
return PaneInfoEncoding.ONE_INDEX
else:
return PaneInfoEncoding.TWO_INDICES
def encode_to_stream(self, value, out, nested):
# type: (windowed_value.PaneInfo, create_OutputStream, bool) -> None
pane_info = value # cast
encoding_type = self._choose_encoding(pane_info)
out.write_byte(pane_info._encoded_byte | (encoding_type << 4))
if encoding_type == PaneInfoEncoding_FIRST:
return
elif encoding_type == PaneInfoEncoding.ONE_INDEX:
out.write_var_int64(value.index)
elif encoding_type == PaneInfoEncoding.TWO_INDICES:
out.write_var_int64(value.index)
out.write_var_int64(value.nonspeculative_index)
else:
raise NotImplementedError('Invalid PaneInfoEncoding: %s' % encoding_type)
def decode_from_stream(self, in_stream, nested):
# type: (create_InputStream, bool) -> windowed_value.PaneInfo
encoded_first_byte = in_stream.read_byte()
base = windowed_value._BYTE_TO_PANE_INFO[encoded_first_byte & 0xF]
assert base is not None
encoding_type = encoded_first_byte >> 4
if encoding_type == PaneInfoEncoding_FIRST:
return base
elif encoding_type == PaneInfoEncoding.ONE_INDEX:
index = in_stream.read_var_int64()
if base.timing == windowed_value.PaneInfoTiming.EARLY:
nonspeculative_index = -1
else:
nonspeculative_index = index
elif encoding_type == PaneInfoEncoding.TWO_INDICES:
index = in_stream.read_var_int64()
nonspeculative_index = in_stream.read_var_int64()View on GitHub (pinned to 12126d8942)
Solutions
- Construct PaneInfo only via its documented constructor/API so the encoding type is derived correctly
- Check that all pipeline components use a consistent Beam version (enum values must match)
- Inspect the PaneInfo object at the failure site and fix its _encoding_type to a valid PaneInfoEncoding member
- Avoid persisting/monkeypatching PaneInfo internals; rely on windowed_value helpers
Example fix
// before
p = windowed_value.PaneInfo(True, False, rel, 1, None)
p._encoding_type = 99 # invalid
coder.encode(p)
// after
from apache_beam.coders.coder_impl import PaneInfoEncoding
if p._encoding_type not in (PaneInfoEncoding.NONE,
PaneInfoEncoding.ONE_INDEX,
PaneInfoEncoding.TWO_INDICES):
p = windowed_value.PaneInfo(p.is_first, p.is_last, p.timing, p.index, p.nonspeculative_index)
coder.encode(p) Defensive patterns
Strategy: validation
Validate before calling
from apache_beam.coders.coder_impl import PaneInfoEncoding
VALID = {PaneInfoEncoding.NONE, PaneInfoEncoding.ONE_INDEX, PaneInfoEncoding.TWO_INDICES}
assert pane._encoding_type in VALID, f'bad encoding type: {pane._encoding_type}' Type guard
def has_valid_pane_encoding(pane) -> bool:
return getattr(pane, '_encoding_type', None) in (
PaneInfoEncoding.NONE, PaneInfoEncoding.ONE_INDEX, PaneInfoEncoding.TWO_INDICES) Try / catch
try:
coder.encode_to_stream(pane, out, nested)
except NotImplementedError as e:
if 'PaneInfoEncoding' in str(e):
raise TypeError(f'Invalid PaneInfo object: {e}') from e
raise Prevention
- Never assign PaneInfo._encoding_type manually; build PaneInfo via its constructor
- Keep the same Beam version across all pipeline components
- Avoid deserializing PaneInfo internals across versions
When it happens
Trigger: Encoding a PaneInfo whose _encoding_type attribute is not one of PaneInfoEncoding.NONE/ONE_INDEX/TWO_INDICES — e.g., a PaneInfo constructed manually with a bogus or out-of-range encoding type, or an enum value from a different Beam version.
Common situations: Hand-constructing PaneInfo objects in tests with an invalid encoding; mixing Beam versions where the PaneInfoEncoding enum changed; monkeypatching or deserializing PaneInfo objects that lost their proper enum type.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Encountered unexpected value for null indicator: '%s'
- Integer value '{value}' is out of the encodable range for Va
- Cannot estimate size for integer value '{value}'. Value is o
- Number of components does not match number of coders.
- Cannot read state-written iterable without state reader.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/38a32e70b0e69633.
Report an issue: GitHub.