apache/cassandra · error · MarshalException

Unable to make boolean from

Error message

Unable to make boolean from '%s'

What it means

BooleanType.fromString throws this when the input string is neither 'true' nor 'false' (case-insensitive). Cassandra's boolean parser accepts only these two literals; anything else (including '1', 'yes', or values with stray whitespace) is rejected. The failing string is included in the message.

Solutions

  1. Use the exact literals true or false (any case, no extra whitespace)
  2. Convert 0/1 or yes/no to true/false in the import/ETL layer
  3. If column holds numeric flags, change type to tinyint and store 0/1
  4. Trim and normalize the value before binding: value.trim().toLowerCase()

Example fix

// before
INSERT INTO t (k, flag) VALUES (1, 'yes');
// after
INSERT INTO t (k, flag) VALUES (1, true);
Defensive patterns

Strategy: validation

Validate before calling

public static void assertBooleanLiteral(String s) {
    String t = s == null ? null : s.trim().toLowerCase();
    if (!"true".equals(t) && !"false".equals(t))
        throw new IllegalArgumentException("Not a boolean literal: " + s);
}

Prevention

When it happens

Trigger: INSERT with '1'/'yes'/'on' or whitespace-padded variants into a boolean column via the fromString path; fromJSONObject with a string that is not true/false; localized boolean representations (e.g. 'vrai').

Common situations: Data imported from CSVs using 0/1 or yes/no conventions; config-driven inserts where booleans render with trailing whitespace; shell env vars carrying '1' for boolean flags.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at src/java/org/apache/cassandra/db/marshal/BooleanType.java:93

    @Override
    public <V> V fromComparableBytes(ValueAccessor<V> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version)
    {
        if (comparableBytes == null)
            return accessor.empty();
        int b = comparableBytes.next();
        return accessor.valueOf(b == 1);
    }

    public ByteBuffer fromString(String source) throws MarshalException
    {

        if (source.isEmpty()|| source.equalsIgnoreCase(Boolean.FALSE.toString()))
            return decompose(false);

        if (source.equalsIgnoreCase(Boolean.TRUE.toString()))
            return decompose(true);

        throw new MarshalException(String.format("Unable to make boolean from '%s'", source));
    }

    @Override
    public Term fromJSONObject(Object parsed) throws MarshalException
    {
        if (parsed instanceof String)
            return new Constants.Value(fromString((String) parsed));
        else if (!(parsed instanceof Boolean))
            throw new MarshalException(String.format(
                    "Expected a boolean value, but got a %s: %s", parsed.getClass().getSimpleName(), parsed));

        return new Constants.Value(getSerializer().serialize((Boolean) parsed));
    }

    @Override
    public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion)
    {
        return getSerializer().deserialize(buffer).toString();

View on GitHub (pinned to 88fd0f6a0e)