{"record":{"id":"5ddc418cf1c757df","repo":"prestodb/presto","slug":"not-a-valid-mode-5ddc41","errorCode":null,"errorMessage":"not a valid mode ","messagePattern":"not a valid mode ","errorType":"exception","errorClass":"ParquetDecodingException","httpStatus":null,"severity":"error","filePath":"presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/rle/BaseRLEBitPackedDecoder.java","lineNumber":119,"sourceCode":"                return true;\n            case PACKED:\n                int numGroups = header >>> 1;\n                currentCount = numGroups * 8;\n                currentBuffer = new int[currentCount];\n                byte[] bytes = new byte[numGroups * bitWidth];\n                int bytesToRead = (int) ceil((double) (currentCount * bitWidth) / 8.0D);\n                bytesToRead = Math.min(bytesToRead, inputStream.available());\n                DataInputStream dataInputStream = new DataInputStream(inputStream);\n                dataInputStream.readFully(bytes, 0, bytesToRead);\n                int valueIndex = 0;\n\n                for (int byteIndex = 0; valueIndex < currentCount; byteIndex += bitWidth) {\n                    packer.unpack8Values(bytes, byteIndex, currentBuffer, valueIndex);\n                    valueIndex += 8;\n                }\n                return true;\n            default:\n                throw new ParquetDecodingException(\"not a valid mode \" + mode);\n        }\n    }\n\n    public enum Mode\n    {\n        RLE,\n        PACKED\n    }\n}\n","sourceCodeStart":101,"sourceCodeEnd":129,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/rle/BaseRLEBitPackedDecoder.java#L101-L129","documentation":"BaseRLEBitPackedDecoder.decode reads one RLE/bit-packed hybrid run; the first varint's LSB holds the mode. Only Mode.RLE (0) and Mode.PACKED_BIT_PACKED (1) are handled; any other mode value is corrupt/unknown and decode throws a ParquetDecodingException. This is the lowest-level guard for the hybrid encoding header in the batch reader.","triggerScenarios":"decode() reads a run header whose mode bits are neither 0 (RLE) nor 1 (PACKED_BIT_PACKED) — e.g. a garbage/truncated header byte or a writer emitting an invalid mode.","commonSituations":"Corrupted or truncated column chunks (partial upload, bad compaction); files written by non-standard or buggy Parquet writers; reading at a wrong offset so random bytes are interpreted as a run header.","solutions":["Validate the file with parquet-tools to locate the corrupt column chunk","Re-copy/re-download the file and compare checksums to rule out truncation","Rewrite the affected file with a standard writer using RLE encoding","If the file is valid in other readers, file a bug with offset details — the reader may be mispositioned"],"exampleFix":"// before: truncated upload leaves run header byte = 0x9A -> unknown mode\n// after: restore the file from a verified source\n//   hadoop fs -checksum src dst  # then retry the query","handlingStrategy":"try-catch","validationCode":"// Detect truncation/corruption before reading:\n// parquet-tools meta file.parquet  # fails fast on corrupt chunk headers","typeGuard":null,"tryCatchPattern":"try {\n    decoder.decode(valuesToRead);\n} catch (ParquetDecodingException e) {\n    if (e.getMessage().startsWith(\"not a valid mode\")) {\n        throw new IOException(\"Corrupt RLE/bit-packed header, file may be truncated\", e);\n    }\n    throw e;\n}","preventionTips":["Verify file checksums after transfer","Avoid partial writes/uploads of Parquet files","Use parquet-tools validation in ingest pipelines","Read files only through supported writers' output"],"tags":["parquet","rle","corrupt-data"],"backgroundTag":"parquet-invalid-encoding-mode","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}