{"record":{"id":"38a32e70b0e69633","repo":"apache/beam","slug":"invalid-paneinfoencoding-s","errorCode":null,"errorMessage":"Invalid PaneInfoEncoding: %s","messagePattern":"Invalid PaneInfoEncoding: (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/coders/coder_impl.py","lineNumber":1524,"sourceCode":"          value._timing == windowed_value.PaneInfoTiming.EARLY):\n      return PaneInfoEncoding.ONE_INDEX\n    else:\n      return PaneInfoEncoding.TWO_INDICES\n\n  def encode_to_stream(self, value, out, nested):\n    # type: (windowed_value.PaneInfo, create_OutputStream, bool) -> None\n    pane_info = value  # cast\n    encoding_type = self._choose_encoding(pane_info)\n    out.write_byte(pane_info._encoded_byte | (encoding_type << 4))\n    if encoding_type == PaneInfoEncoding_FIRST:\n      return\n    elif encoding_type == PaneInfoEncoding.ONE_INDEX:\n      out.write_var_int64(value.index)\n    elif encoding_type == PaneInfoEncoding.TWO_INDICES:\n      out.write_var_int64(value.index)\n      out.write_var_int64(value.nonspeculative_index)\n    else:\n      raise NotImplementedError('Invalid PaneInfoEncoding: %s' % encoding_type)\n\n  def decode_from_stream(self, in_stream, nested):\n    # type: (create_InputStream, bool) -> windowed_value.PaneInfo\n    encoded_first_byte = in_stream.read_byte()\n    base = windowed_value._BYTE_TO_PANE_INFO[encoded_first_byte & 0xF]\n    assert base is not None\n    encoding_type = encoded_first_byte >> 4\n    if encoding_type == PaneInfoEncoding_FIRST:\n      return base\n    elif encoding_type == PaneInfoEncoding.ONE_INDEX:\n      index = in_stream.read_var_int64()\n      if base.timing == windowed_value.PaneInfoTiming.EARLY:\n        nonspeculative_index = -1\n      else:\n        nonspeculative_index = index\n    elif encoding_type == PaneInfoEncoding.TWO_INDICES:\n      index = in_stream.read_var_int64()\n      nonspeculative_index = in_stream.read_var_int64()","sourceCodeStart":1506,"sourceCodeEnd":1542,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/coders/coder_impl.py#L1506-L1542","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\np = windowed_value.PaneInfo(True, False, rel, 1, None)\np._encoding_type = 99  # invalid\n coder.encode(p)\n// after\nfrom apache_beam.coders.coder_impl import PaneInfoEncoding\nif p._encoding_type not in (PaneInfoEncoding.NONE,\n                            PaneInfoEncoding.ONE_INDEX,\n                            PaneInfoEncoding.TWO_INDICES):\n    p = windowed_value.PaneInfo(p.is_first, p.is_last, p.timing, p.index, p.nonspeculative_index)\ncoder.encode(p)","handlingStrategy":"validation","validationCode":"from apache_beam.coders.coder_impl import PaneInfoEncoding\nVALID = {PaneInfoEncoding.NONE, PaneInfoEncoding.ONE_INDEX, PaneInfoEncoding.TWO_INDICES}\nassert pane._encoding_type in VALID, f'bad encoding type: {pane._encoding_type}'","typeGuard":"def has_valid_pane_encoding(pane) -> bool:\n    return getattr(pane, '_encoding_type', None) in (\n        PaneInfoEncoding.NONE, PaneInfoEncoding.ONE_INDEX, PaneInfoEncoding.TWO_INDICES)","tryCatchPattern":"try:\n    coder.encode_to_stream(pane, out, nested)\nexcept NotImplementedError as e:\n    if 'PaneInfoEncoding' in str(e):\n        raise TypeError(f'Invalid PaneInfo object: {e}') from e\n    raise","preventionTips":["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"],"tags":["python","apache-beam","coding","pane-info","enum"],"backgroundTag":"invalid-enum-value","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"}