apache/cassandra · error · SyntaxException

Invalid boolean value

Error message

Invalid boolean value %s for '%s'. Positive values can be '1', 'true' or 'yes'. Negative values can be '0', 'false' or 'no'.

What it means

PropertyDefinitions.parseBoolean() (via getBoolean) accepts only the token sets '1'/'true'/'yes' (positive) and '0'/'false'/'no' (negative) for boolean-typed CQL properties. Any other string is rejected with a SyntaxException listing the accepted values. This keeps property parsing strict and locale/format independent.

Solutions

  1. Use one of: '1', 'true', 'yes' (or '0', 'false', 'no') for the property value
  2. Remove stray quotes/whitespace from the value (write true, not 'true' or ' true ')
  3. Convert True/False (Python/JSON style) to lowercase true/false when generating CQL
  4. Map on/off or enabled/disabled to true/false before emitting the statement

Example fix

// before
ALTER TABLE t WITH caching = {'keys': 'ALL', 'rows_per_partition': enabled};
// after
ALTER TABLE t WITH caching = {'keys': 'ALL', 'rows_per_partition': 'no'};
Defensive patterns

Strategy: validation

Validate before calling

const v = String(value).trim().toLowerCase(); if (!['1','true','yes','0','false','no'].includes(v)) throw new Error(`Invalid boolean for ${key}: ${value}`);

Try / catch

try { runCql(stmt); } catch (e) { if (e.message.includes('Invalid boolean value')) fixBooleanLiterals(stmt); else throw e; }

Prevention

When it happens

Trigger: Setting a boolean property in CQL (e.g. WITH speculative_retry = 'TRUE' style mistakes, or compaction/compaction-throughput-table-wait-adjacent boolean options) with a value like 'True' variants not matching the regexes, 'on', 'enabled', 'y', or with stray whitespace/quotes inside the string.

Common situations: Users writing 'on'/'off' or 'enabled'/'disabled' out of habit; accidental capital-letter-only handling issues when the value arrives quoted ('true' with literal quotes); tools generating CQL with Python-style True/False literals.

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/cd34363c8ff6298c. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/statements/PropertyDefinitions.java:136

    public boolean getBoolean(String key, boolean defaultValue) throws SyntaxException
    {
        String value = getString(key);
        return value != null ? parseBoolean(key, value) : defaultValue;
    }

    public static boolean parseBoolean(String key, String value) throws SyntaxException
    {
        if (null == value)
            throw new IllegalArgumentException("value argument can't be null");

        String lowerCasedValue = toLowerCaseLocalized(value);

        if (POSITIVE_PATTERN.matcher(lowerCasedValue).matches())
            return true;
        else if (NEGATIVE_PATTERN.matcher(lowerCasedValue).matches())
            return false;

        throw new SyntaxException(format("Invalid boolean value %s for '%s'. " +
                                         "Positive values can be '1', 'true' or 'yes'. " +
                                         "Negative values can be '0', 'false' or 'no'.",
                                         value, key));
    }

    public int getInt(String key, int defaultValue) throws SyntaxException
    {
        String value = getString(key);
        return value != null ? parseInt(key, value) : defaultValue;
    }

    public static int parseInt(String key, String value) throws SyntaxException
    {
        if (null == value)
            throw new IllegalArgumentException("value argument can't be null");

        try
        {

View on GitHub (pinned to 88fd0f6a0e)