apache/cassandra · error · ConfigurationException

Invalid value %s for '%s' compaction sub-option - must be an

Error message

Invalid value %s for '%s' compaction sub-option - must be an integer

What it means

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.

Source

Thrown at src/java/org/apache/cassandra/schema/CompactionParams.java:233

            Throwable cause = e.getCause() == null
                            ? e
                            : e.getCause();

            throw new ConfigurationException(format("%s.validateOptions() threw an error: %s %s",
                                                    klass.getName(),
                                                    cause.getClass().getName(),
                                                    cause.getMessage()),
                                             e);
        }
        catch (IllegalAccessException e)
        {
            throw new ConfigurationException("Cannot access method validateOptions in " + klass.getName(), e);
        }

        String minThreshold = options.get(Option.MIN_THRESHOLD.toString());
        if (minThreshold != null && !StringUtils.isNumeric(minThreshold))
        {
            throw new ConfigurationException(format("Invalid value %s for '%s' compaction sub-option - must be an integer",
                                                    minThreshold,
                                                    Option.MIN_THRESHOLD));
        }

        String maxThreshold = options.get(Option.MAX_THRESHOLD.toString());
        if (maxThreshold != null && !StringUtils.isNumeric(maxThreshold))
        {
            throw new ConfigurationException(format("Invalid value %s for '%s' compaction sub-option - must be an integer",
                                                    maxThreshold,
                                                    Option.MAX_THRESHOLD));
        }

        if (minCompactionThreshold() <= 0 || maxCompactionThreshold() <= 0)
        {
            throw new ConfigurationException("Disabling compaction by setting compaction thresholds to 0 has been removed,"
                                             + " set the compaction option 'enabled' to false instead.");
        }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Set min_threshold to a plain integer string, e.g. {'min_threshold': '4'}
  2. Strip whitespace and non-numeric characters from the value before submitting the schema
  3. If the value comes from user input or config, parse and validate it with an integer check before passing to setCompactionParameters

Example fix

// before
compaction = {'class': 'SizeTieredCompactionStrategy', 'min_threshold': 'four'}
// after
compaction = {'class': 'SizeTieredCompactionStrategy', 'min_threshold': '4'}
Defensive patterns

Strategy: validation

Validate before calling

String v = opts.get("min_threshold");
if (v != null && !v.trim().matches("\\d+")) throw new IllegalArgumentException("min_threshold must be an integer: " + v);

Type guard

boolean isValidIntOption(String v) { return v != null && v.trim().matches("\\d+"); }

Try / catch

try { schemaChange(ddl); } catch (ConfigurationException e) { if (e.getMessage().contains("must be an integer")) { /* fix compaction option values */ } throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/81dc4bded55c5da0. Report an issue: GitHub.