{"record":{"id":"81dc4bded55c5da0","repo":"apache/cassandra","slug":"invalid-value-s-for-s-compaction-sub-option","errorCode":null,"errorMessage":"Invalid value %s for '%s' compaction sub-option - must be an integer","messagePattern":"Invalid value (.+?) for '(.+?)' compaction sub-option - must be an integer","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/schema/CompactionParams.java","lineNumber":233,"sourceCode":"            Throwable cause = e.getCause() == null\n                            ? e\n                            : e.getCause();\n\n            throw new ConfigurationException(format(\"%s.validateOptions() threw an error: %s %s\",\n                                                    klass.getName(),\n                                                    cause.getClass().getName(),\n                                                    cause.getMessage()),\n                                             e);\n        }\n        catch (IllegalAccessException e)\n        {\n            throw new ConfigurationException(\"Cannot access method validateOptions in \" + klass.getName(), e);\n        }\n\n        String minThreshold = options.get(Option.MIN_THRESHOLD.toString());\n        if (minThreshold != null && !StringUtils.isNumeric(minThreshold))\n        {\n            throw new ConfigurationException(format(\"Invalid value %s for '%s' compaction sub-option - must be an integer\",\n                                                    minThreshold,\n                                                    Option.MIN_THRESHOLD));\n        }\n\n        String maxThreshold = options.get(Option.MAX_THRESHOLD.toString());\n        if (maxThreshold != null && !StringUtils.isNumeric(maxThreshold))\n        {\n            throw new ConfigurationException(format(\"Invalid value %s for '%s' compaction sub-option - must be an integer\",\n                                                    maxThreshold,\n                                                    Option.MAX_THRESHOLD));\n        }\n\n        if (minCompactionThreshold() <= 0 || maxCompactionThreshold() <= 0)\n        {\n            throw new ConfigurationException(\"Disabling compaction by setting compaction thresholds to 0 has been removed,\"\n                                             + \" set the compaction option 'enabled' to false instead.\");\n        }\n","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/schema/CompactionParams.java#L215-L251","documentation":"Cassandra validates the min_threshold compaction sub-option at schema definition time. If the supplied value is not numeric, CompactionParams.validate throws a ConfigurationException before the table schema is accepted. This prevents silent misconfiguration of compaction thresholds.","triggerScenarios":"Calling ALTER TABLE/CREATE TABLE with compaction = {'class': '...', 'min_threshold': 'abc'}; programmatically calling setCompactionParameters with a non-numeric min_threshold string in the options map.","commonSituations":"Hand-edited schema files with typos like 'min_threshold': '4x' or quoted/whitespace-polluted values; cqlsh clients building option strings; tooling that serializes integers incorrectly.","solutions":["Set min_threshold to a plain integer string, e.g. {'min_threshold': '4'}","Strip whitespace and non-numeric characters from the value before submitting the schema","If the value comes from user input or config, parse and validate it with an integer check before passing to setCompactionParameters"],"exampleFix":"// before\ncompaction = {'class': 'SizeTieredCompactionStrategy', 'min_threshold': 'four'}\n// after\ncompaction = {'class': 'SizeTieredCompactionStrategy', 'min_threshold': '4'}","handlingStrategy":"validation","validationCode":"String v = opts.get(\"min_threshold\");\nif (v != null && !v.trim().matches(\"\\\\d+\")) throw new IllegalArgumentException(\"min_threshold must be an integer: \" + v);","typeGuard":"boolean isValidIntOption(String v) { return v != null && v.trim().matches(\"\\\\d+\"); }","tryCatchPattern":"try { schemaChange(ddl); } catch (ConfigurationException e) { if (e.getMessage().contains(\"must be an integer\")) { /* fix compaction option values */ } throw e; }","preventionTips":["Always quote thresholds as plain integer strings in DDL","Validate user-supplied compaction options with an integer regex before schema submission","Test generated DDL against a test keyspace before production"],"tags":["cassandra","configuration","schema","compaction"],"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"}