{"record":{"id":"1eb92a4251c7bc20","repo":"apache/cassandra","slug":"messagetemplate-caller-provided-message-template-1eb92a","errorCode":null,"errorMessage":"messageTemplate (caller-provided message template, 2 args)","messagePattern":"messageTemplate \\(caller-provided message template, 2 args\\)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/RequestValidations.java","lineNumber":97,"sourceCode":"    }\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)\n            throw invalidRequest(messageTemplate, arg1, arg2);\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     * @param arg3 the third 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,\n                                 Object arg3) throws InvalidRequestException","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/RequestValidations.java#L79-L115","documentation":"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.","triggerScenarios":"Validation call sites using two interpolated values (e.g. expected vs actual) where the checked condition fails during statement prepare/execute.","commonSituations":"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.","solutions":["Read both interpolated values in the message to see the expected-vs-actual mismatch","Adjust the CQL statement so the validated relationship holds","Check the schema (system_schema) for types involved if the mismatch is type-related"],"exampleFix":"// before\ncheckTrue(a.type.equals(b.type), \"type mismatch: %s vs %s\", a.type, b.type); // throws\n// after\n-- use compatible types, e.g. cast or alter the table so both columns share a type","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { session.execute(stmt); }\ncatch (InvalidRequestException e) { // expected-vs-actual in message\n  log.warn(\"CQL validation failed: {}\", e.getMessage()); }","preventionTips":["Check column types in system_schema.columns when comparing/joining columns","Avoid mixing differently-typed columns in the same expression"],"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"}