apache/shenyu · error · IllegalArgumentException

entry size exceeds maximum allowed value.

Error message

entry size exceeds maximum allowed value.

What it means

ZipUtil.unzip throws this IllegalArgumentException when a single archive entry's uncompressed size exceeds maxEntrySize. It enforces the cap incrementally while streaming, so a single huge (possibly zip-bomb) entry is rejected before consuming unbounded memory.

Solutions

  1. Split large files out of the archive or compress/trim the offending entry.
  2. Raise the maxEntrySize parameter if your valid artifacts are larger than the current limit.
  3. Check the entry's uncompressed size beforehand with `unzip -l file.zip`.

Example fix

// before
ZipUtil.unzip(in, maxEntries, 1_000_000L, maxTotalSize); // 1MB cap
// after
ZipUtil.unzip(in, maxEntries, 10_000_000L, maxTotalSize); // 10MB cap
Defensive patterns

Strategy: validation

Validate before calling

try (ZipFile zf = new ZipFile(zipFile)) {
    long max = zf.stream().filter(e -> !e.isDirectory())
        .mapToLong(ZipEntry::getSize).max().orElse(0L);
    if (max > maxEntrySize) {
        throw new IllegalArgumentException("largest entry " + max + " exceeds limit " + maxEntrySize);
    }
}

Try / catch

try {
    ZipUtil.unzip(in, maxEntryCount, maxEntrySize, maxTotalSize);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("entry size exceeds")) {
        log.error("Single entry too large; split or compress the file");
    }
}

Prevention

When it happens

Trigger: Unzipping an archive containing one file whose decompressed byte length surpasses maxEntrySize.

Common situations: Uploading a zip that legitimately contains a large data/config file; malicious zip-bomb archives with highly compressible content.

Understand the failure class

Background: "File too large" / "file size exceeds limit" errors: why libraries cap file sizes and how to fix them — this error's family across 46 libraries.

Related errors


AI-assisted analysis of apache/shenyu@567142e072 (2026-09-12). Data as JSON: /api/errors/57cc56f2e2759537. Report an issue: GitHub.

Appendix: source

Thrown at shenyu-admin/src/main/java/org/apache/shenyu/admin/utils/ZipUtil.java:121

        try (ZipInputStream zipIn = new ZipInputStream(new ByteArrayInputStream(source))) {
            ZipEntry entry;
            while (Objects.nonNull(entry = zipIn.getNextEntry())) {
                if (entry.isDirectory()) {
                    continue;
                }
                entryCount++;
                if (entryCount > maxEntryCount) {
                    throw new IllegalArgumentException("entry count exceeds maximum of " + maxEntryCount);
                }
                try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
                    byte[] buffer = new byte[1024];
                    int offset;
                    long entrySize = 0L;
                    while ((offset = zipIn.read(buffer)) != -1) {
                        entrySize += offset;
                        totalSize += offset;
                        if (entrySize > maxEntrySize) {
                            throw new IllegalArgumentException("entry size exceeds maximum allowed value.");
                        }
                        if (totalSize > maxTotalSize) {
                            throw new IllegalArgumentException("total size exceeds maximum allowed value.");
                        }
                        out.write(buffer, 0, offset);
                    }
                    String entryName = entry.getName();
                    itemList.add(new ZipItem(entryName, out.toString(StandardCharsets.UTF_8)));
                } catch (IOException e) {
                    LOG.error("unzip error", e);
                }
            }
        } catch (IOException e) {
            LOG.error("unzip error", e);
        }
        return new UnZipResult(itemList);
    }

View on GitHub (pinned to 567142e072)