{"record":{"id":"e1ac37962deabd1b","repo":"prestodb/presto","slug":"not-a-valid-mode","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/DefinitionLevelDecoder.java","lineNumber":66,"sourceCode":"\n            int chunkSize = Math.min(remainingToCopy, currentCount);\n            switch (mode) {\n                case RLE: {\n                    int rleValue = currentValue;\n                    int endIndex = destinationIndex + chunkSize;\n                    while (destinationIndex < endIndex) {\n                        values[destinationIndex] = rleValue;\n                        destinationIndex++;\n                    }\n                    break;\n                }\n                case PACKED: {\n                    System.arraycopy(currentBuffer, currentBuffer.length - currentCount, values, destinationIndex, chunkSize);\n                    destinationIndex += chunkSize;\n                    break;\n                }\n                default:\n                    throw new ParquetDecodingException(\"not a valid mode \" + mode);\n            }\n            currentCount -= chunkSize;\n            remainingToCopy -= chunkSize;\n        }\n        checkState(remainingToCopy == 0, \"Failed to copy the requested number of DLs\");\n    }\n}\n","sourceCodeStart":48,"sourceCodeEnd":74,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/DefinitionLevelDecoder.java#L48-L74","documentation":"ParquetDecodingException thrown by DefinitionLevelDecoder.readNext() when the internal Mode enum is neither RLE nor PACKED — the decoder's current buffer state was created with an unknown mode. In practice this indicates corrupted definition-level data or a decoder state bug, since modes are only set from RLE/packed headers.","triggerScenarios":"readNext() copies definition levels from the current buffer in chunks; if mode is not MODE.RLE or MODE.PACKED when copying, the default case throws. Only reachable if mode was parsed from a malformed RLE header or constructed incorrectly.","commonSituations":"Corrupted definition-level byte stream (bad RLE bit-width/header bytes); truncated page data; files from writers emitting non-standard level encodings.","solutions":["Validate the file with parquet-tools; regenerate if the page is corrupt.","Check the page's definition-level header bytes (bit width, RLE/packed selector) for corruption.","Upgrade Presto — header-parsing robustness fixes exist across versions.","If the writer is in-house, ensure it writes valid RLE-encoded definition levels per spec."],"exampleFix":"// before\nDLDecoder dl = pageDecoder.getDefinitionLevelDecoder(); // later throws: not a valid mode X\n// after\ntry {\n    dl = pageDecoder.getDefinitionLevelDecoder();\n} catch (ParquetDecodingException e) {\n    throw new RuntimeException(\"Corrupt definition levels in \" + parquetPath, e);\n}","handlingStrategy":"validation","validationCode":"// sanity-check the definition-level RLE header before decoding\nint bitWidth = buffer[0] & 0xFF;\nif (bitWidth > 8) throw new IllegalStateException(\"Invalid DL bit width \" + bitWidth + \" in \" + path);\n","typeGuard":null,"tryCatchPattern":"try {\n    chunk = reader.readNext();\n} catch (ParquetDecodingException e) {\n    if (e.getMessage().startsWith(\"not a valid mode\")) {\n        // corrupt definition levels: quarantine file, regenerate\n    }\n    throw e;\n}","preventionTips":["Validate files with parquet-tools before querying","Ensure writers emit spec-compliant RLE level data","Keep the reader version current (header-parsing fixes)","Regenerate files with corrupt level headers instead of retrying"],"tags":["parquet","decoding","definition-levels","corruption"],"backgroundTag":"parquet-corrupt-page","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"}