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
- Set the option to 'true' or 'false' exactly
- Normalize 1/0 or yes/no booleans in the config generator before applying
- Remove the option to use the default (false)
- 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
- Normalize 1/0, yes/no, on/off to true/false in config generators
- Trim whitespace from boolean strings
- Keep TWCS option templates with literal 'true'/'false' placeholders
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
- concurrent_compactors should be strictly greater than 0, but
- Could not set new local compaction strategy: <cause message>
- '%s' should be either 'true' or 'false', not '%s'
- '%s' should either be 'true' or 'false', not %s
- enabled should either be 'true' or 'false', not %s
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/dbea6eae06881842.
Report an issue: GitHub.