{"record":{"id":"c97eb87951548773","repo":"apache/cassandra","slug":"s-d-is-invalid","errorCode":null,"errorMessage":"%s=%d is invalid","messagePattern":"(.+?)=(.+?) is invalid","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/compress/ZstdCompressorBase.java","lineNumber":175,"sourceCode":"        try\n        {\n            Zstd.compress(output, input, compressionLevel(), ENABLE_CHECKSUM_FLAG);\n        } catch (Exception e)\n        {\n            throw new IOException(\"Compression failed\", e);\n        }\n    }\n\n    /**\n     * Check if the given compression level is valid. This can be a negative value as well.\n     *\n     * @param level compression level\n     */\n    public static void validateCompressionLevel(int level)\n    {\n        if (level < FAST_COMPRESSION_LEVEL || level > BEST_COMPRESSION_LEVEL)\n        {\n            throw new IllegalArgumentException(String.format(\"%s=%d is invalid\", COMPRESSION_LEVEL_OPTION_NAME, level));\n        }\n    }\n\n    /**\n     * Get the supplied compression level; otherwise, use the default\n     *\n     * @param options compression options\n     * @return compression level\n     */\n    public static int getOrDefaultCompressionLevel(Map<String, String> options)\n    {\n        if (options == null)\n            return DEFAULT_COMPRESSION_LEVEL;\n\n        String val = options.get(COMPRESSION_LEVEL_OPTION_NAME);\n\n        if (val == null)\n            return DEFAULT_COMPRESSION_LEVEL;","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/compress/ZstdCompressorBase.java#L157-L193","documentation":"Zstd compression levels in Cassandra are restricted to the range [FAST_COMPRESSION_LEVEL, BEST_COMPRESSION_LEVEL]. validateCompressionLevel throws IllegalArgumentException with this formatted message when the configured 'compression_level' option falls outside that range. It runs when the compression parameters are parsed for a table.","triggerScenarios":"Issuing CREATE/ALTER TABLE with compression = {'class':'ZstdCompressor','compression_level': N} where N < FAST_COMPRESSION_LEVEL or N > BEST_COMPRESSION_LEVEL (e.g. level 100 or -1000).","commonSituations":"Copy-pasting raw zstd library levels (zstd CLI accepts 1-22 plus extreme negatives) that exceed Cassandra's allowed bounds; typos like an extra digit; tooling emitting levels from another system's config.","solutions":["Set compression_level to a value inside the accepted range (check FAST_COMPRESSION_LEVEL / BEST_COMPRESSION_LEVEL constants in ZstdCompressorBase for your version).","Omit compression_level entirely to use the default level if no non-default tuning is needed.","Update provisioning/ORM templates that generate the compression option to clamp the level to the valid range."],"exampleFix":"// before\ncompression = {'class':'ZstdCompressor','compression_level':100}\n// after\ncompression = {'class':'ZstdCompressor','compression_level':3}","handlingStrategy":"validation","validationCode":"int FAST = ZstdCompressorBase.FAST_COMPRESSION_LEVEL;\nint BEST = ZstdCompressorBase.BEST_COMPRESSION_LEVEL;\nif (level < FAST || level > BEST) throw new IllegalArgumentException(\"compression_level \" + level + \" outside [\" + FAST + \",\" + BEST + \"]\");","typeGuard":null,"tryCatchPattern":"try {\n    validateCompressionLevel(level);\n} catch (IllegalArgumentException e) {\n    level = ZstdCompressorBase.DEFAULT_COMPRESSION_LEVEL; // fall back\n}","preventionTips":["Clamp configured levels to the library's documented range before applying them to schema.","Do not copy raw zstd CLI levels (1-22/negatives) blindly into Cassandra options.","Validate compression options in CI schema tests."],"tags":["zstd","compression-level","configuration","validation"],"backgroundTag":"value-out-of-range","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"}