apache/cassandra · error · InvalidRequestException
message (caller-provided message string)
Error message
message (caller-provided message string)
What it means
RequestValidations.checkTrue is a CQL3 utility that throws an InvalidRequestException carrying the caller-supplied message when the given boolean expression is false. It is the shared guard used across statement validation. The message text is determined entirely by each call site, not by this method.
Source
Thrown at src/java/org/apache/cassandra/cql3/statements/RequestValidations.java:61
* if (value < 0.0)
* throw RequestValidations.invalidRequest("negative value: %s", toReadableText(value));
* </pre>
* </p>
*/
public final class RequestValidations
{
/**
* Checks that the specified expression is {@code true}. If not an {@code InvalidRequestException} will
* be thrown.
*
* @param expression the expression to test
* @param message the error message
* @throws InvalidRequestException if the specified expression is {@code false}.
*/
public static void checkTrue(boolean expression, String message) throws InvalidRequestException
{
if (!expression)
throw invalidRequest(message);
}
/**
* 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 messageArg the message argument
* @throws InvalidRequestException if the specified expression is {@code false}.
*/
public static void checkTrue(boolean expression,
String messageTemplate,
Object messageArg) throws InvalidRequestException
{
if (!expression)
throw invalidRequest(messageTemplate, messageArg);
}View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Read the exception message; it names the exact violated precondition from the failing checkTrue call site
- Fix the CQL statement so the validated condition holds
- If raised from your own code, ensure the caller checks the condition before invoking the API
Example fix
// before checkTrue(rowCount > 0, "expected at least one row"); // throws when empty // after if (rowCount > 0) checkTrue(rowCount > 0, "expected at least one row");
Defensive patterns
Strategy: try-catch
Try / catch
try { session.execute(query); }
catch (InvalidRequestException e) { log.error("Invalid request: {}", e.getMessage()); throw new QueryValidationException(e); } Prevention
- Validate CQL statements against schema before executing
- Keep statement construction type-safe with the driver's query builder
- Test queries against a local single-node cluster
When it happens
Trigger: Any CQL statement validation path that calls checkTrue(cond, msg) where the condition evaluates to false — e.g. malformed queries violating preconditions checked during parsing/prepare/execute of statements.
Common situations: Developers hitting it indirectly via a malformed CQL query (bad TTL, invalid options, wrong argument combinations); contributors calling checkTrue with a condition that can legitimately be false on user input.
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
- messageTemplate (caller-provided message template, 1 arg)
- messageTemplate (caller-provided message template, 2 args)
- messageTemplate (caller-provided message template, 3 args)
- Invalid tuple literal for %s: too many elements. Type %s exp
- REVOKE operation is not supported by AllowAllAuthorizer
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/9d8fdbb199f81651.
Report an issue: GitHub.