apache/seatunnel · error · IllegalArgumentException

Unknown

Error message

Unknown: ${type}

What it means

EdgePacketCompressor.compress switches over the EdgePacketCompressionType constant and has an explicit default branch that throws IllegalArgumentException("Unknown: " + type). This is an internal invariant guard: with the current enum set, NONE/GZIP/ZLIB/DEFLATE are all handled, so reaching default means the enum gained a new constant without a matching compression implementation.

Solutions

  1. Ensure all seatunnel-edge-agent modules are the same version; re-shade/redeploy so enum and compressor match.
  2. Add a case for the new EdgePacketCompressionType constant in compress() (and its helper) if you extended the enum.
  3. Avoid reflection or serialization tricks that could surface a constant the switch does not know.
  4. As a workaround, set compression to "gzip" (widely supported) until versions are aligned.

Example fix

// before
case DEFLATE:
    return zlibCompress(data, true);
default:
    throw new IllegalArgumentException("Unknown: " + type);

// after
case DEFLATE:
    return zlibCompress(data, true);
case ZSTD:
    return zstdCompress(data);
default:
    throw new IllegalArgumentException("Unknown: " + type);
Defensive patterns

Strategy: try-catch

Validate before calling

if (type == null) {
    throw new IllegalStateException("Compression type must be resolved via EdgePacketCompressionType.from before compress()");
}
// In tests, cover every enum constant:
for (EdgePacketCompressionType t : EdgePacketCompressionType.values()) {
    assertDoesNotThrow(() -> EdgePacketCompressor.compress(t, new byte[16]));
}

Type guard

boolean isHandledByCompressor(EdgePacketCompressionType t) {
    switch (t) {
        case NONE: case GZIP: case ZLIB: case DEFLATE: return true;
        default: return false;
    }
}

Try / catch

try {
    byte[] wire = EdgePacketCompressor.compress(type, data);
} catch (IllegalArgumentException e) {
    LOG.error("Compressor does not support " + type + "; check module version alignment", e);
    throw e;
}

Prevention

When it happens

Trigger: Calling compress with an EdgePacketCompressionType constant that the switch does not handle — practically only possible with a newer enum constant running against an older compressor implementation, or a hand-constructed/mismatched enum instance.

Common situations: Mixed-version deployment where the config/enum jar is newer than the transport jar; custom builds that added an enum constant but forgot the compress() branch; reflection-driven construction of enum constants.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/a7d4254459c9f908. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-edge-agent/seatunnel-edge-agent-transport/src/main/java/org/apache/seatunnel/edge/agent/transport/packet/EdgePayloadCompressor.java:39

import java.io.IOException;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;
import java.util.zip.GZIPOutputStream;

public class EdgePayloadCompressor {

    public static byte[] compress(byte[] data, EdgePacketCompressionType type) throws IOException {
        switch (type) {
            case NONE:
                return data;
            case GZIP:
                return gzipCompress(data);
            case ZLIB:
                return zlibCompress(data, false);
            case DEFLATE:
                return zlibCompress(data, true);
            default:
                throw new IllegalArgumentException("Unknown: " + type);
        }
    }

    private static byte[] gzipCompress(byte[] data) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try (GZIPOutputStream gzip = new GZIPOutputStream(out)) {
            gzip.write(data);
        }
        return out.toByteArray();
    }

    private static byte[] zlibCompress(byte[] data, boolean nowrap) throws IOException {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try (DeflaterOutputStream deflaterOut =
                new DeflaterOutputStream(out, new Deflater(Deflater.DEFAULT_COMPRESSION, nowrap))) {
            deflaterOut.write(data);
        }
        return out.toByteArray();

View on GitHub (pinned to cf67b549a7)