apache/cassandra · error · ConfigurationException

'%s' should be either 'true' or 'false', not '%s'

Error message

'%s' should be either 'true' or 'false', not '%s'

What it means

Thrown as a ConfigurationException when the unchecked_tombstone_compaction option is present but its value is not the literal string 'true' or 'false' (case-insensitive). This boolean option forces tombstone compaction regardless of threshold, so Cassandra strictly validates it.

Source

Thrown at src/java/org/apache/cassandra/db/compaction/AbstractCompactionStrategy.java:491

            try
            {
                long tombstoneCompactionInterval = Long.parseLong(interval);
                if (tombstoneCompactionInterval < 0)
                {
                    throw new ConfigurationException(String.format("%s must be greater than 0, but was %d", TOMBSTONE_COMPACTION_INTERVAL_OPTION, tombstoneCompactionInterval));
                }
            }
            catch (NumberFormatException e)
            {
                throw new ConfigurationException(String.format("%s is not a parsable int (base10) for %s", interval, TOMBSTONE_COMPACTION_INTERVAL_OPTION), e);
            }
        }

        String unchecked = options.get(UNCHECKED_TOMBSTONE_COMPACTION_OPTION);
        if (unchecked != null)
        {
            if (!unchecked.equalsIgnoreCase("true") && !unchecked.equalsIgnoreCase("false"))
                throw new ConfigurationException(String.format("'%s' should be either 'true' or 'false', not '%s'", UNCHECKED_TOMBSTONE_COMPACTION_OPTION, unchecked));
        }

        String logAll = options.get(LOG_ALL_OPTION);
        if (logAll != null)
        {
            if (!logAll.equalsIgnoreCase("true") && !logAll.equalsIgnoreCase("false"))
            {
                throw new ConfigurationException(String.format("'%s' should either be 'true' or 'false', not %s", LOG_ALL_OPTION, logAll));
            }
        }

        String compactionEnabled = options.get(COMPACTION_ENABLED);
        if (compactionEnabled != null)
        {
            if (!compactionEnabled.equalsIgnoreCase("true") && !compactionEnabled.equalsIgnoreCase("false"))
            {
                throw new ConfigurationException(String.format("enabled should either be 'true' or 'false', not %s", compactionEnabled));
            }

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Set the option to the exact string 'true' or 'false'.
  2. Remove the option if the default (false) behavior is desired.
  3. Fix generating tools to emit Java-style boolean literals.

Example fix

// before
{'unchecked_tombstone_compaction': 'yes'}
// after
{'unchecked_tombstone_compaction': 'true'}
Defensive patterns

Strategy: validation

Validate before calling

String v = options.get("unchecked_tombstone_compaction");
if (v != null && !v.equalsIgnoreCase("true") && !v.equalsIgnoreCase("false")) throw new IllegalArgumentException("must be true/false: " + v);

Try / catch

try { session.execute(alterCql); } catch (ConfigurationException e) { /* normalize boolean literal and retry */ }

Prevention

When it happens

Trigger: CREATE/ALTER TABLE with {'unchecked_tombstone_compaction': 'yes'}, '1', 'on', or any value other than true/false (any casing).

Common situations: Porting YAML/JSON-style boolean conventions ('yes'/'no', '1'/'0') into CQL compaction options, tooling that serializes booleans non-uniformly.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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