apache/cassandra · error · InvalidRequestException
messageTemplate (caller-provided message template, 1 arg)
Error message
messageTemplate (caller-provided message template, 1 arg)
What it means
RequestValidations.checkTrue(boolean, String template, Object arg) throws InvalidRequestException with a one-argument formatted message when the expression is false. Same shared validation guard as the plain-message variant; the template and arg come from the call site.
Source
Thrown at src/java/org/apache/cassandra/cql3/statements/RequestValidations.java:78
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);
}
/**
* 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)View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Inspect the formatted message to identify the offending value
- Correct the CQL statement so the condition holds
- Reproduce the query with the reported value removed or replaced by a valid one
Example fix
// before checkTrue(ttl >= 0, "TTL must be non-negative, got %s", ttl); // throws // after checkTrue(ttl >= 0, "TTL must be non-negative, got %s", ttl); // pass ttl >= 0, e.g. TTL 0
Defensive patterns
Strategy: try-catch
Try / catch
try { session.execute(query, values); }
catch (InvalidRequestException e) { // message names the offending value
throw new IllegalArgumentException("Bad query value: " + e.getMessage(), e); } Prevention
- Validate argument values (ranges, types) in application code before binding
- Use bound statements with correct codecs so types are checked early
When it happens
Trigger: Any validation site calling checkTrue(cond, "...%s...", x) where cond is false while validating a CQL statement (e.g. a wrong argument value interpolated into the message).
Common situations: Malformed CQL queries failing a precondition check whose message reports the offending value (e.g. unsupported consistency, bad identifier, wrong literal type).
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
- message (caller-provided message string)
- 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/1b1f918e89bb4eec.
Report an issue: GitHub.