{"record":{"id":"1e7b5f5cfb601589","repo":"prestodb/presto","slug":"not-a-valid-mode-1e7b5f","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/BinaryRLEDictionaryValuesDecoder.java","lineNumber":80,"sourceCode":"                    final int rleValueLength = dictionary.getLength(rleValue);\n                    while (destinationIndex < endIndex) {\n                        dictionaries[destinationIndex++] = rleValue;\n                    }\n                    bufferSize += (rleValueLength * numEntriesToFill);\n                    break;\n                }\n                case PACKED: {\n                    final int[] localBuffer = currentBuffer;\n                    final BinaryBatchDictionary localDictionary = dictionary;\n                    for (int srcIndex = currentBuffer.length - currentCount; destinationIndex < endIndex; srcIndex++, destinationIndex++) {\n                        int dictionaryId = localBuffer[srcIndex];\n                        dictionaries[destinationIndex] = dictionaryId;\n                        bufferSize += localDictionary.getLength(dictionaryId);\n                    }\n                    break;\n                }\n                default:\n                    throw new ParquetDecodingException(\"not a valid mode \" + this.mode);\n            }\n            currentCount -= numEntriesToFill;\n            remainingToCopy -= numEntriesToFill;\n        }\n\n        checkState(remainingToCopy == 0, \"Invalid read size request\");\n        return new RLEValueBuffer(bufferSize, dictionaries);\n    }\n\n    @Override\n    public int readIntoBuffer(byte[] byteBuffer, int bufferIndex, int[] offsets, int offsetIndex, ValueBuffer valueBuffer)\n    {\n        checkArgument(byteBuffer.length - bufferIndex >= valueBuffer.getBufferSize(), \"not enough space in the input buffer\");\n\n        RLEValueBuffer rleValueBuffer = (RLEValueBuffer) valueBuffer;\n        final int[] dictionaryIds = rleValueBuffer.getDictionaryIds();\n        final int numEntries = dictionaryIds.length;\n","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/rle/BinaryRLEDictionaryValuesDecoder.java#L62-L98","documentation":"BinaryRLEDictionaryValuesDecoder.readNext fills value buffers from RLE/bit-packed dictionary indices; the mode switch only supports RLE and PACKED_BIT_PACKED. An unknown mode in the index stream's run header makes the dictionary-id data undecodable, so a ParquetDecodingException is thrown with this.mode. It indicates corrupt or unsupported dictionary index data.","triggerScenarios":"readNext() reaches the default branch because a run header in the dictionary-index stream encodes a mode outside Mode.RLE/Mode.PACKED_BIT_PACKED.","commonSituations":"Corrupted dictionary-encoded column chunks; files produced by writers emitting non-standard hybrid headers; byte-offset misalignment after earlier decode errors causing headers to be read at wrong positions.","solutions":["Validate the column chunk with parquet-tools (it will also fail if data is corrupt)","Disable dictionary reading issues by rewriting the file without dictionary encoding or with a standard writer","Restore the file from a clean source and compare checksums","Upgrade presto-parquet if a newer writer encoding is involved; otherwise file a bug with file metadata"],"exampleFix":"// before: file with corrupt dictionary index header\n// after: rewrite without dictionary encoding to sidestep the bad header\n//   parquet.writer.dictionary=false (writer config) or rewrite via Spark/Trino","handlingStrategy":"try-catch","validationCode":"// parquet-tools meta file.parquet | grep <column>  # confirm RLE_DICTIONARY/PLAIN_DICTIONARY and intact chunk sizes","typeGuard":null,"tryCatchPattern":"try {\n    decoder.readNext(batchSize);\n} catch (ParquetDecodingException e) {\n    if (e.getMessage().startsWith(\"not a valid mode\")) {\n        // retry against a re-written copy of the file; do not loop-retry the same bytes\n    }\n    throw e;\n}","preventionTips":["Validate dictionary-encoded columns at ingest with parquet-tools","Rewrite suspect files without dictionary encoding to isolate header corruption","Enforce checksum verification in data pipelines","Keep writer and reader versions compatible"],"tags":["parquet","rle","dictionary-encoding"],"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"}