{"record":{"id":"1b1f918e89bb4eec","repo":"apache/cassandra","slug":"messagetemplate-caller-provided-message-template","errorCode":null,"errorMessage":"messageTemplate (caller-provided message template, 1 arg)","messagePattern":"messageTemplate \\(caller-provided message template, 1 arg\\)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/RequestValidations.java","lineNumber":78,"sourceCode":"        if (!expression)\n            throw invalidRequest(message);\n    }\n\n    /**\n     * Checks that the specified expression is <code>true</code>. If not an {@code InvalidRequestException} will\n     * be thrown.\n     *\n     * @param expression the expression to test\n     * @param messageTemplate the template used to build the error message\n     * @param messageArg the message argument\n     * @throws InvalidRequestException if the specified expression is {@code false}.\n     */\n    public static void checkTrue(boolean expression,\n                                 String messageTemplate,\n                                 Object messageArg) throws InvalidRequestException\n    {\n        if (!expression)\n            throw invalidRequest(messageTemplate, messageArg);\n    }\n\n    /**\n     * Checks that the specified expression is <code>true</code>. If not an {@code InvalidRequestException} will\n     * be thrown.\n     *\n     * @param expression the expression to test\n     * @param messageTemplate the template used to build the error message\n     * @param arg1 the first message argument\n     * @param arg2 the second message argument\n     * @throws InvalidRequestException if the specified expression is {@code false}.\n     */\n    public static void checkTrue(boolean expression,\n                                 String messageTemplate,\n                                 Object arg1,\n                                 Object arg2) throws InvalidRequestException\n    {\n        if (!expression)","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/RequestValidations.java#L60-L96","documentation":"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.","triggerScenarios":"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).","commonSituations":"Malformed CQL queries failing a precondition check whose message reports the offending value (e.g. unsupported consistency, bad identifier, wrong literal type).","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"],"exampleFix":"// before\ncheckTrue(ttl >= 0, \"TTL must be non-negative, got %s\", ttl); // throws\n// after\ncheckTrue(ttl >= 0, \"TTL must be non-negative, got %s\", ttl); // pass ttl >= 0, e.g. TTL 0","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { session.execute(query, values); }\ncatch (InvalidRequestException e) { // message names the offending value\n  throw new IllegalArgumentException(\"Bad query value: \" + e.getMessage(), e); }","preventionTips":["Validate argument values (ranges, types) in application code before binding","Use bound statements with correct codecs so types are checked early"],"tags":["cql","validation","invalid-request"],"backgroundTag":"invalid-argument-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}