{"record":{"id":"fa4e150a3a812d96","repo":"apache/cassandra","slug":"unknown-compression-algorithm-s","errorCode":null,"errorMessage":"Unknown compression algorithm: %s","messagePattern":"Unknown compression algorithm: (.+?)","errorType":"exception","errorClass":"ProtocolException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/transport/messages/StartupMessage.java","lineNumber":119,"sourceCode":"        {\n            String compression = toLowerCaseLocalized(options.get(COMPRESSION));\n            if (compression.equals(\"snappy\"))\n            {\n                if (Compressor.SnappyCompressor.instance == null)\n                    throw new ProtocolException(\"This instance does not support Snappy compression\");\n\n                if (getSource().header.version.isGreaterOrEqualTo(ProtocolVersion.V5))\n                    throw new ProtocolException(\"Snappy compression is not supported in protocol V5\");\n\n                connection.setCompressor(Compressor.SnappyCompressor.instance);\n            }\n            else if (compression.equals(\"lz4\"))\n            {\n                connection.setCompressor(Compressor.LZ4Compressor.instance);\n            }\n            else\n            {\n                throw new ProtocolException(String.format(\"Unknown compression algorithm: %s\", compression));\n            }\n        }\n\n        connection.setThrowOnOverload(\"1\".equals(options.get(THROW_ON_OVERLOAD)));\n\n        ClientState clientState = state.getClientState();\n        clientState.setClientOptions(options);\n        String driverName = options.get(DRIVER_NAME);\n        String driverVersion = options.get(DRIVER_VERSION);\n        if (null != driverName)\n        {\n            clientState.setDriverName(driverName);\n            clientState.setDriverVersion(driverVersion);\n        }\n\n        Guardrails.minimumClientDriverVersion.guard(driverName, driverVersion, clientState);\n\n        IAuthenticator authenticator = DatabaseDescriptor.getAuthenticator();","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/transport/messages/StartupMessage.java#L101-L137","documentation":"The STARTUP message's COMPRESSION option must be one of the recognized algorithms ('snappy' or 'lz4'). Any other value causes Cassandra to throw this ProtocolException, formatting the unrecognized algorithm name into the message, and the connection is rejected during handshake.","triggerScenarios":"Client sends STARTUP with an option like COMPRESSION=zstd, COMPRESSION=gzip, or any typo/other string that is neither 'snappy' nor 'lz4'.","commonSituations":"Driver misconfiguration using an algorithm Cassandra's native protocol does not support (e.g. zstd); typos in connection options in custom clients; copy-pasting compression settings from other databases into a Cassandra driver config.","solutions":["Set the client's compression option to 'lz4' (supported in all versions)","Use 'snappy' only if the client will negotiate protocol V4 or lower and Snappy is available","Remove the COMPRESSION option entirely to connect without compression"],"exampleFix":"// before (custom client STARTUP options)\noptions.put(StartupMessage.COMPRESSION, \"zstd\");\n// after\noptions.put(StartupMessage.COMPRESSION, \"lz4\");","handlingStrategy":"validation","validationCode":"const ALLOWED = ['snappy','lz4'];\nif (compression && !ALLOWED.includes(compression.toLowerCase())) throw new Error('Unsupported Cassandra compression: ' + compression);","typeGuard":"function isCassandraCompression(v) { return typeof v === 'string' && ['snappy','lz4'].includes(v.toLowerCase()); }","tryCatchPattern":"catch ProtocolException 'Unknown compression algorithm' during connect and retry with COMPRESSION unset","preventionTips":["Only configure snappy or lz4 for Cassandra native protocol","Lowercase the value exactly as the server compares it","Never copy compression names from other database drivers"],"tags":["protocol","compression","invalid-argument","handshake"],"backgroundTag":"invalid-enum-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}