apache/cassandra · error · ConfigurationException

%s is not 'true' or 'false' (%s)

Error message

%s is not 'true' or 'false' (%s)

What it means

The unsafe_aggressive_sstable_expiration TWCS option must be the literal string 'true' or 'false' (case-insensitive). validateOptions throws ConfigurationException for any other value, naming the option key and the offending value.

Source

Thrown at src/java/org/apache/cassandra/db/compaction/TimeWindowCompactionStrategyOptions.java:155

        try
        {
            long expiredCheckFrequency = optionValue == null ? DEFAULT_EXPIRED_SSTABLE_CHECK_FREQUENCY_SECONDS : Long.parseLong(optionValue);
            if (expiredCheckFrequency < 0)
            {
                throw new ConfigurationException(String.format("%s must not be negative, but was %d", EXPIRED_SSTABLE_CHECK_FREQUENCY_SECONDS_KEY, expiredCheckFrequency));
             }
        }
        catch (NumberFormatException e)
        {
            throw new ConfigurationException(String.format("%s is not a parsable int (base10) for %s", optionValue, EXPIRED_SSTABLE_CHECK_FREQUENCY_SECONDS_KEY), e);
        }


        optionValue = options.get(UNSAFE_AGGRESSIVE_SSTABLE_EXPIRATION_KEY);
        if (optionValue != null)
        {
            if (!(optionValue.equalsIgnoreCase("true") || optionValue.equalsIgnoreCase("false")))
                throw new ConfigurationException(String.format("%s is not 'true' or 'false' (%s)", UNSAFE_AGGRESSIVE_SSTABLE_EXPIRATION_KEY, optionValue));

            if (optionValue.equalsIgnoreCase("true") && !UNSAFE_AGGRESSIVE_SSTABLE_EXPIRATION_ENABLED)
                throw new ConfigurationException(String.format("%s is requested but not allowed, restart cassandra with -D%s=true to allow it",
                                                               UNSAFE_AGGRESSIVE_SSTABLE_EXPIRATION_KEY, ALLOW_UNSAFE_AGGRESSIVE_SSTABLE_EXPIRATION.getKey()));
        }

        uncheckedOptions.remove(COMPACTION_WINDOW_SIZE_KEY);
        uncheckedOptions.remove(COMPACTION_WINDOW_UNIT_KEY);
        uncheckedOptions.remove(TIMESTAMP_RESOLUTION_KEY);
        uncheckedOptions.remove(EXPIRED_SSTABLE_CHECK_FREQUENCY_SECONDS_KEY);
        uncheckedOptions.remove(UNSAFE_AGGRESSIVE_SSTABLE_EXPIRATION_KEY);

        uncheckedOptions = SizeTieredCompactionStrategyOptions.validateOptions(options, uncheckedOptions);

        return uncheckedOptions;
    }
}

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Set the option to 'true' or 'false' exactly
  2. Normalize 1/0 or yes/no booleans in the config generator before applying
  3. Remove the option to use the default (false)
  4. Validate boolean strings client-side before issuing the ALTER/CREATE TABLE

Example fix

// before
'unsafe_aggressive_sstable_expiration': '1'
// after
'unsafe_aggressive_sstable_expiration': 'true'
Defensive patterns

Strategy: validation

Validate before calling

if (opts.containsKey("unsafe_aggressive_sstable_expiration")) {
    String v = opts.get("unsafe_aggressive_sstable_expiration").trim();
    if (!v.equalsIgnoreCase("true") && !v.equalsIgnoreCase("false"))
        throw new IllegalArgumentException("unsafe_aggressive_sstable_expiration must be 'true' or 'false'");
}

Type guard

static boolean isBooleanOption(String s) { return "true".equalsIgnoreCase(s == null ? null : s.trim()) || "false".equalsIgnoreCase(s == null ? null : s.trim()); }

Try / catch

try {
    session.execute(alterStmt);
} catch (RuntimeException e) {
    if (e.getMessage().contains("is not 'true' or 'false'")) { /* fix value */ }
    throw e;
}

Prevention

When it happens

Trigger: validateOptions with unsafe_aggressive_sstable_expiration set to anything other than true/false, e.g. '1', '0', 'yes', 'enabled', 'True ' with whitespace, 'on'.

Common situations: Using 1/0 or yes/no from other config conventions; tools that serialize booleans as '1'; whitespace introduced by templating.

Related errors


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