{"record":{"id":"dfcb680476e3f57f","repo":"apache/incubator-seata","slug":"zip-decompress-error","errorCode":null,"errorMessage":"Zip decompress error","messagePattern":"Zip decompress error","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"compressor/seata-compressor-zip/src/main/java/org/apache/seata/compressor/zip/ZipUtil.java","lineNumber":66,"sourceCode":"        }\n    }\n\n    public static byte[] decompress(byte[] bytes) {\n        if (bytes == null) {\n            throw new NullPointerException(\"bytes is null\");\n        }\n        ByteArrayOutputStream out = new ByteArrayOutputStream();\n        try (ZipInputStream zip = new ZipInputStream(new ByteArrayInputStream(bytes))) {\n            byte[] buffer = new byte[BUFFER_SIZE];\n            while (zip.getNextEntry() != null) {\n                int n;\n                while ((n = zip.read(buffer)) > -1) {\n                    out.write(buffer, 0, n);\n                }\n            }\n            return out.toByteArray();\n        } catch (IOException e) {\n            throw new RuntimeException(\"Zip decompress error\", e);\n        }\n    }\n}\n","sourceCodeStart":48,"sourceCodeEnd":70,"githubUrl":"https://github.com/apache/incubator-seata/blob/e01f97c6db397165050caa6764020410c2c8199a/compressor/seata-compressor-zip/src/main/java/org/apache/seata/compressor/zip/ZipUtil.java#L48-L70","documentation":"Wrapped IOException from ZipUtil.decompress thrown as RuntimeException('Zip decompress error', e). It fires when ZipInputStream cannot parse the payload: not a zip stream, truncated data, unsupported compression method, or a corrupt entry header. The original exception is preserved as cause.","triggerScenarios":"Passing gzip/lz4/zstd-compressed bytes to the zip decompressor; truncated arrays from partial reads or wrong length prefixes; corrupt stored rollback data; empty non-null arrays causing 'Not in ZIP format' errors.","commonSituations":"Compressor type mismatch between seata endpoints; DB storing compressed undo data damaged by charset conversion; middleware mangling binary bodies; version upgrades changing default compressor.","solutions":["Check the cause: ZipException 'Not in ZIP format' = wrong codec, 'unexpected EOF' = truncation.","Align compressor configuration on client and server.","Regenerate or purge corrupted stored data instead of retrying.","Preflight the payload with a zip magic check (PK\\x03\\x04) when data provenance is uncertain."],"exampleFix":"// before\nbyte[] out = ZipUtil.decompress(bytes);\n\n// after\nif (bytes.length < 4 || bytes[0] != 'P' || bytes[1] != 'K') {\n    throw new IllegalArgumentException(\"payload is not a zip stream\");\n}\nbyte[] out = ZipUtil.decompress(bytes);","handlingStrategy":"try-catch","validationCode":"boolean isZip(byte[] b) {\n    return b != null && b.length >= 4 && b[0] == 'P' && b[1] == 'K';\n}","typeGuard":null,"tryCatchPattern":"try {\n    byte[] out = ZipUtil.decompress(bytes);\n} catch (RuntimeException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"Zip decompress error\")) {\n        // wrong codec or truncated data; inspect e.getCause() (ZipException) and reject\n    } else { throw e; }\n}","preventionTips":["Align compressor type on all endpoints before enabling compression","Check the PK magic bytes when decompressing data from untrusted stores","Purge/regenerate corrupted persisted payloads rather than retrying decompression"],"tags":["zip","compression","corrupt-data","io","seata"],"backgroundTag":null,"analyzedSha":"e01f97c6db397165050caa6764020410c2c8199a","analyzedAt":"2026-08-14T10:23:53.097Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}