{"record":{"id":"051dbfd85bea7571","repo":"apache/cassandra","slug":"s-must-be-non-negative-d","errorCode":null,"errorMessage":"%s must be non negative: %d","messagePattern":"(.+?) must be non negative: (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategyOptions.java","lineNumber":75,"sourceCode":"        try\n        {\n            return optionValue == null ? defaultValue : Double.parseDouble(optionValue);\n        }\n        catch (NumberFormatException e)\n        {\n            throw new ConfigurationException(String.format(\"%s is not a parsable float for %s\", optionValue, key), e);\n        }\n    }\n\n    public static Map<String, String> validateOptions(Map<String, String> options, Map<String, String> uncheckedOptions) throws ConfigurationException\n    {\n        String optionValue = options.get(MIN_SSTABLE_SIZE_KEY);\n        try\n        {\n            long minSSTableSize = optionValue == null ? DEFAULT_MIN_SSTABLE_SIZE : Long.parseLong(optionValue);\n            if (minSSTableSize < 0)\n            {\n                throw new ConfigurationException(String.format(\"%s must be non negative: %d\", MIN_SSTABLE_SIZE_KEY, minSSTableSize));\n            }\n        }\n        catch (NumberFormatException e)\n        {\n            throw new ConfigurationException(String.format(\"%s is not a parsable int (base10) for %s\", optionValue, MIN_SSTABLE_SIZE_KEY), e);\n        }\n\n        double bucketLow = parseDouble(options, BUCKET_LOW_KEY, DEFAULT_BUCKET_LOW);\n        double bucketHigh = parseDouble(options, BUCKET_HIGH_KEY, DEFAULT_BUCKET_HIGH);\n        if (bucketHigh <= bucketLow)\n        {\n            throw new ConfigurationException(String.format(\"%s value (%s) is less than or equal to the %s value (%s)\",\n                                                           BUCKET_HIGH_KEY, bucketHigh, BUCKET_LOW_KEY, bucketLow));\n        }\n\n        uncheckedOptions.remove(MIN_SSTABLE_SIZE_KEY);\n        uncheckedOptions.remove(BUCKET_LOW_KEY);\n        uncheckedOptions.remove(BUCKET_HIGH_KEY);","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategyOptions.java#L57-L93","documentation":"ConfigurationException thrown by SizeTieredCompactionStrategyOptions.validateOptions when the min_sstable_size option parses as a valid long but is negative. Minimum SSTable size for size-tiered bucketing must be >= 0, so a negative value is rejected before the strategy is instantiated.","triggerScenarios":"CREATE/ALTER TABLE with compaction option {'min_sstable_size': '-1024'} — any value < 0 supplied for min_sstable_size on SizeTieredCompactionStrategy.","commonSituations":"Hand-edited schema options where a '-' was typed accidentally; a sizing tool writing negative bytes after a failed computation; copy-paste of a value intended for another option.","solutions":["Set min_sstable_size to a non-negative byte value (e.g. '52428800' for 50MB) or remove it to use the default (50MB).","Re-run ALTER TABLE with the corrected compaction map.","Add caller-side validation rejecting negative byte sizes before applying schema options."],"exampleFix":"// before\n{'class':'SizeTieredCompactionStrategy','min_sstable_size':'-1024'}\n// after\n{'class':'SizeTieredCompactionStrategy','min_sstable_size':'52428800'}","handlingStrategy":"validation","validationCode":"long minSstableSize = Long.parseLong(opts.getOrDefault(\"min_sstable_size\", \"52428800\"));\nif (minSstableSize < 0) throw new IllegalArgumentException(\"min_sstable_size must be >= 0\");","typeGuard":null,"tryCatchPattern":"try { schema.alterTable(cql); } catch (ConfigurationException e) { if (e.getMessage().contains(\"must be non negative\")) { /* fix the option and retry */ } else throw e; }","preventionTips":["Never emit negative byte sizes; clamp with Math.max(0, size).","Sanitize option values for stray '-' signs before building the compaction map.","Keep sizes as plain decimal byte strings in templates."],"tags":["compaction","configuration","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}