apache/cassandra · error · InvalidRequestException

messageTemplate (caller-provided message template, 2 args)

Error message

messageTemplate (caller-provided message template, 2 args)

What it means

RequestValidations.checkTrue(boolean, String template, Object arg1, Object arg2) throws InvalidRequestException with a two-argument formatted message when the expression is false. It is a standard guard in CQL statement validation; message content is defined by each caller.

Solutions

  1. Read both interpolated values in the message to see the expected-vs-actual mismatch
  2. Adjust the CQL statement so the validated relationship holds
  3. Check the schema (system_schema) for types involved if the mismatch is type-related

Example fix

// before
checkTrue(a.type.equals(b.type), "type mismatch: %s vs %s", a.type, b.type); // throws
// after
-- use compatible types, e.g. cast or alter the table so both columns share a type
Defensive patterns

Strategy: try-catch

Try / catch

try { session.execute(stmt); }
catch (InvalidRequestException e) { // expected-vs-actual in message
  log.warn("CQL validation failed: {}", e.getMessage()); }

Prevention

When it happens

Trigger: Validation call sites using two interpolated values (e.g. expected vs actual) where the checked condition fails during statement prepare/execute.

Common situations: Queries mixing incompatible elements, e.g. comparing columns of different types or wrong number/order of clauses, with both offending items named in the message.

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

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/statements/RequestValidations.java:97

    }

    /**
     * Checks that the specified expression is <code>true</code>. If not an {@code InvalidRequestException} will
     * be thrown.
     *
     * @param expression the expression to test
     * @param messageTemplate the template used to build the error message
     * @param arg1 the first message argument
     * @param arg2 the second message argument
     * @throws InvalidRequestException if the specified expression is {@code false}.
     */
    public static void checkTrue(boolean expression,
                                 String messageTemplate,
                                 Object arg1,
                                 Object arg2) throws InvalidRequestException
    {
        if (!expression)
            throw invalidRequest(messageTemplate, arg1, arg2);
    }

    /**
     * Checks that the specified expression is <code>true</code>. If not an {@code InvalidRequestException} will
     * be thrown.
     *
     * @param expression the expression to test
     * @param messageTemplate the template used to build the error message
     * @param arg1 the first message argument
     * @param arg2 the second message argument
     * @param arg3 the third message argument
     * @throws InvalidRequestException if the specified expression is {@code false}.
     */
    public static void checkTrue(boolean expression,
                                 String messageTemplate,
                                 Object arg1,
                                 Object arg2,
                                 Object arg3) throws InvalidRequestException

View on GitHub (pinned to 88fd0f6a0e)