{"record":{"id":"aa9691e5931066cd","repo":"apache/beam","slug":"invalid-pane-encoding","errorCode":null,"errorMessage":"Invalid pane encoding ","messagePattern":"Invalid pane encoding ","errorType":"exception","errorClass":"CoderException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/PaneInfo.java","lineNumber":347,"sourceCode":"    private enum Encoding {\n      FIRST,\n      ONE_INDEX,\n      TWO_INDICES;\n\n      // NOTE: Do not reorder fields. The ordinal is used as part of\n      // the encoding.\n\n      public final byte tag;\n\n      Encoding() {\n        assert ordinal() < 16;\n        tag = (byte) (ordinal() << 4);\n      }\n\n      public static Encoding fromTag(byte b) throws CoderException {\n        int index = b >> 4;\n        if (index < 0 || index >= values().length) {\n          throw new CoderException(\"Invalid pane encoding \" + index);\n        }\n        return Encoding.values()[b >> 4];\n      }\n    }\n\n    private Encoding chooseEncoding(PaneInfo value) {\n      if ((value.index == 0 && value.nonSpeculativeIndex == 0) || value.timing == Timing.UNKNOWN) {\n        return Encoding.FIRST;\n      } else if (value.index == value.nonSpeculativeIndex || value.timing == Timing.EARLY) {\n        return Encoding.ONE_INDEX;\n      } else {\n        return Encoding.TWO_INDICES;\n      }\n    }\n\n    public static final PaneInfoCoder INSTANCE = new PaneInfoCoder();\n\n    public static PaneInfoCoder of() {","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/PaneInfo.java#L329-L365","documentation":"PaneInfo.Encoding.fromTag decodes the high nibble of the pane's tag byte into an Encoding enum. If the nibble does not map to a known encoding, the encoded element is corrupt or was produced by an incompatible Beam version, and a CoderException is thrown.","triggerScenarios":"Decoding a PaneInfo from a byte stream whose tag byte's high nibble (b >> 4) is negative or >= Encoding.values().length — i.e. a corrupted serialized element, a hand-crafted/truncated stream, or data written by a newer Beam version with extra encodings.","commonSituations":"Reading already-serialized runner state or test data written by a different Beam version; corrupted transport/storage of encoded bundles; custom runners mangling the first byte of PaneInfo encodings.","solutions":["Verify the data was serialized and deserialized with the same Apache Beam version on both ends.","Re-generate or re-ingest the corrupted data; check storage/transport for truncation or bit corruption.","Inspect the offending first byte to confirm whether it is truncated/garbage vs a legitimately newer encoding.","If bridging versions is required, upgrade both producer and consumer to a common Beam release before exchanging encoded data."],"exampleFix":"// before\nEncoding e = Encoding.fromTag(rawByte); // throws CoderException on garbage byte\n// after\nint index = rawByte >> 4;\nif (index < 0 || index >= Encoding.values().length) {\n  LOG.warn(\"Corrupt pane tag byte 0x{}; defaulting to NO_FIRING\", Integer.toHexString(rawByte & 0xFF));\n  return PaneInfo.NO_FIRING;\n}\nEncoding e = Encoding.fromTag(rawByte);","handlingStrategy":"try-catch","validationCode":"boolean validPaneTag(byte b) {\n  int index = b >> 4;\n  return index >= 0 && index < PaneInfo.Encoding.values().length;\n}\n// validate before decoding raw bytes from external storage","typeGuard":null,"tryCatchPattern":"try {\n  PaneInfo info = paneInfoCoder.decode(stream);\n} catch (CoderException e) {\n  LOG.error(\"Corrupt PaneInfo tag byte; data may be truncated or written by another Beam version\", e);\n  // skip element / re-ingest / dead-letter\n}","preventionTips":["Keep producer and consumer on the same Beam version.","Guard external storage of encoded elements against truncation.","Validate raw tag bytes before decoding externally stored data.","Add round-trip coder tests when upgrading Beam versions."],"tags":["java","apache-beam","coding","deserialization"],"backgroundTag":"protobuf-unmarshal-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}