{"record":{"id":"61f10247630ca281","repo":"prestodb/presto","slug":"invalid-compressed-stream","errorCode":null,"errorMessage":"Invalid compressed stream","messagePattern":"Invalid compressed stream","errorType":"exception","errorClass":"OrcCorruptionException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/OrcSnappyDecompressor.java","lineNumber":51,"sourceCode":"    }\n\n    @Override\n    public int decompress(byte[] input, int offset, int length, OutputBuffer output)\n            throws OrcCorruptionException\n    {\n        try {\n            int uncompressedLength = SnappyDecompressor.getUncompressedLength(input, offset);\n            if (uncompressedLength > maxBufferSize) {\n                throw new OrcCorruptionException(orcDataSourceId, \"Snappy requires buffer (%s) larger than max size (%s)\", uncompressedLength, maxBufferSize);\n            }\n\n            // Snappy decompressor is more efficient if there's at least a long's worth of extra space\n            // in the output buffer\n            byte[] buffer = output.initialize(uncompressedLength + SIZE_OF_LONG);\n            return decompressor.decompress(input, offset, length, buffer, 0, buffer.length);\n        }\n        catch (MalformedInputException e) {\n            throw new OrcCorruptionException(e, orcDataSourceId, \"Invalid compressed stream\");\n        }\n    }\n\n    @Override\n    public String toString()\n    {\n        return \"snappy\";\n    }\n}\n","sourceCodeStart":33,"sourceCodeEnd":61,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/OrcSnappyDecompressor.java#L33-L61","documentation":"The Aircompressor Snappy decompressor throws MalformedInputException when the compressed bytes do not conform to the Snappy format. The decompressor translates that into OrcCorruptionException(\"Invalid compressed stream\") with the cause chained.","triggerScenarios":"decompress() calls decompressor.decompress and the underlying Snappy decoder detects malformed input at the given offset/length — corrupt chunk data or misidentified compression kind.","commonSituations":"Corrupted files (bit rot, bad transfers), reading a file whose compression kind metadata disagrees with the actual chunk encoding, writer bugs, mixing non-Snappy data flagged as Snappy.","solutions":["Verify the file checksum / re-transfer the file","Confirm the footer's compression kind matches the actual chunk encoding","Try reading with a different tool (e.g. orc-tools) to confirm corruption","Regenerate the file from the source if it is corrupt"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check file integrity before reading\nFileStatus st = fs.getFileStatus(path);\nif (st.getLen() != expectedLen || checksumMismatch(path)) { throw new IOException(\"corrupt file\"); }","typeGuard":null,"tryCatchPattern":"try { reader = new OrcReader(...); }\ncatch (OrcCorruptionException e) {\n    if (e.getCause() instanceof MalformedInputException) {\n        /* re-fetch file / regenerate before failing the job */\n    }\n}","preventionTips":["Checksum files after transfer and before read","Keep writer chunk encoding and footer compression kind consistent","Use orc-tools to sanity-check suspect files"],"tags":["orc","snappy","decompression","corruption"],"backgroundTag":"invalid-compressed-stream","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"}