apache/cassandra · error · InvalidRequestException

Illegal value for boolean option '':

Error message

Illegal value for boolean option '': 

What it means

Thrown by NonTokenizingOptions.validateBoolean when a SAI non-tokenizing analyzer boolean option (case_sensitive, normalize, ascii) has a non-empty value that is not case-insensitively 'true' or 'false'. Only those two literals are accepted; values like 'yes', '1', or 'TRUE ' fail.

Source

Thrown at src/java/org/apache/cassandra/index/sai/analyzer/NonTokenizingOptions.java:156

                    boolean boolValue = validateBoolean(entry.getValue(), ASCII);
                    builder = builder.ascii(boolValue);
                    break;
                }
            }
        }
        return builder.build();
    }

    private static boolean validateBoolean(String value, String option)
    {
        if (Strings.isNullOrEmpty(value))
        {
            throw new InvalidRequestException("Empty value for boolean option '" + option + '\'');
        }

        if (!value.equalsIgnoreCase(Boolean.TRUE.toString()) && !value.equalsIgnoreCase(Boolean.FALSE.toString()))
        {
            throw new InvalidRequestException("Illegal value for boolean option '" + option + "': " + value);
        }

        return Boolean.parseBoolean(value);
    }
}

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Change the value to 'true' or 'false' (case-insensitive)
  2. Replace 1/0, yes/no, on/off with their boolean literals
  3. Trim whitespace from the option value
  4. Validate option values against [true, false] before building the CQL

Example fix

// before
WITH OPTIONS = {'case_sensitive': 'yes'}
// after
WITH OPTIONS = {'case_sensitive': 'false'}
Defensive patterns

Strategy: validation

Validate before calling

String v = opts.get("case_sensitive");
if (v != null && !v.equalsIgnoreCase("true") && !v.equalsIgnoreCase("false"))
    throw new IllegalArgumentException("case_sensitive must be 'true' or 'false', got: " + v);

Try / catch

try { session.execute(createIndexCql); }
catch (InvalidRequestException e) {
    if (e.getMessage().startsWith("Illegal value for boolean option")) { /* normalize to true/false and retry */ }
    else throw e;
}

Prevention

When it happens

Trigger: CREATE CUSTOM INDEX ... WITH OPTIONS = {'normalize': 'yes'} or {'ascii': '1'} — any string other than 'true'/'false' (case-insensitive) passed to NonTokenizingOptions.fromMap.

Common situations: Users porting from other databases where 'yes'/'no' or 1/0 booleans are accepted; YAML/JSON-ish habits ('on'/'off'); trailing whitespace or quotes left in the CQL string.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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