{"record":{"id":"a7d4254459c9f908","repo":"apache/seatunnel","slug":"unknown-type","errorCode":null,"errorMessage":"Unknown: ${type}","messagePattern":"Unknown: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-edge-agent/seatunnel-edge-agent-transport/src/main/java/org/apache/seatunnel/edge/agent/transport/packet/EdgePayloadCompressor.java","lineNumber":39,"sourceCode":"import java.io.IOException;\nimport java.util.zip.Deflater;\nimport java.util.zip.DeflaterOutputStream;\nimport java.util.zip.GZIPOutputStream;\n\npublic class EdgePayloadCompressor {\n\n    public static byte[] compress(byte[] data, EdgePacketCompressionType type) throws IOException {\n        switch (type) {\n            case NONE:\n                return data;\n            case GZIP:\n                return gzipCompress(data);\n            case ZLIB:\n                return zlibCompress(data, false);\n            case DEFLATE:\n                return zlibCompress(data, true);\n            default:\n                throw new IllegalArgumentException(\"Unknown: \" + type);\n        }\n    }\n\n    private static byte[] gzipCompress(byte[] data) throws IOException {\n        ByteArrayOutputStream out = new ByteArrayOutputStream();\n        try (GZIPOutputStream gzip = new GZIPOutputStream(out)) {\n            gzip.write(data);\n        }\n        return out.toByteArray();\n    }\n\n    private static byte[] zlibCompress(byte[] data, boolean nowrap) throws IOException {\n        ByteArrayOutputStream out = new ByteArrayOutputStream();\n        try (DeflaterOutputStream deflaterOut =\n                new DeflaterOutputStream(out, new Deflater(Deflater.DEFAULT_COMPRESSION, nowrap))) {\n            deflaterOut.write(data);\n        }\n        return out.toByteArray();","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-edge-agent/seatunnel-edge-agent-transport/src/main/java/org/apache/seatunnel/edge/agent/transport/packet/EdgePayloadCompressor.java#L21-L57","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure all seatunnel-edge-agent modules are the same version; re-shade/redeploy so enum and compressor match.","Add a case for the new EdgePacketCompressionType constant in compress() (and its helper) if you extended the enum.","Avoid reflection or serialization tricks that could surface a constant the switch does not know.","As a workaround, set compression to \"gzip\" (widely supported) until versions are aligned."],"exampleFix":"// before\ncase DEFLATE:\n    return zlibCompress(data, true);\ndefault:\n    throw new IllegalArgumentException(\"Unknown: \" + type);\n\n// after\ncase DEFLATE:\n    return zlibCompress(data, true);\ncase ZSTD:\n    return zstdCompress(data);\ndefault:\n    throw new IllegalArgumentException(\"Unknown: \" + type);","handlingStrategy":"try-catch","validationCode":"if (type == null) {\n    throw new IllegalStateException(\"Compression type must be resolved via EdgePacketCompressionType.from before compress()\");\n}\n// In tests, cover every enum constant:\nfor (EdgePacketCompressionType t : EdgePacketCompressionType.values()) {\n    assertDoesNotThrow(() -> EdgePacketCompressor.compress(t, new byte[16]));\n}","typeGuard":"boolean isHandledByCompressor(EdgePacketCompressionType t) {\n    switch (t) {\n        case NONE: case GZIP: case ZLIB: case DEFLATE: return true;\n        default: return false;\n    }\n}","tryCatchPattern":"try {\n    byte[] wire = EdgePacketCompressor.compress(type, data);\n} catch (IllegalArgumentException e) {\n    LOG.error(\"Compressor does not support \" + type + \"; check module version alignment\", e);\n    throw e;\n}","preventionTips":["Add a unit test that iterates all enum constants and calls compress() so a new constant without a branch fails CI.","Keep enum and compressor in the same module to prevent version skew.","In fat-jar builds, verify no stale EdgePacketCompressionType class is bundled.","When adding an enum constant, update compress(), decompress(), and from() together."],"tags":["enum","compression","internal-error","version-mismatch"],"backgroundTag":"unsupported-enum-value","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}