{"record":{"id":"b1b6962a759fec10","repo":"apache/cassandra","slug":"message-caller-provided-message-string-checkcont-b1b696","errorCode":null,"errorMessage":"message (caller-provided message string, checkContainsOnly)","messagePattern":"message \\(caller-provided message string, checkContainsOnly\\)","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/cql3/statements/RequestValidations.java","lineNumber":189,"sourceCode":"            throw invalidRequest(message);\n    }\n\n    /**\n     * Checks that the specified list contains only the specified elements.\n     *\n     * @param list the list to test\n     * @param expectedElements the expected elements\n     * @param message the error message\n     * @throws InvalidRequestException if the specified list contains duplicates.\n     */\n    public static <E> void checkContainsOnly(List<E> list,\n                                             List<E> expectedElements,\n                                             String message) throws InvalidRequestException\n    {\n        List<E> copy = new ArrayList<>(list);\n        copy.removeAll(expectedElements);\n        if (!copy.isEmpty())\n            throw invalidRequest(message);\n    }\n\n    /**\n     * Checks that the specified expression is {@code false}. 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>true</code>.\n     */\n    public static void checkFalse(boolean expression,\n                                  String messageTemplate,\n                                  Object messageArg) throws InvalidRequestException\n    {\n        checkTrue(!expression, messageTemplate, messageArg);\n    }\n","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cql3/statements/RequestValidations.java#L171-L207","documentation":"RequestValidations.checkContainsOnly(List<E> list, List<E> expectedElements, String message) throws InvalidRequestException if `list` contains any elements not in `expectedElements`. It validates that a user-supplied list is a subset of an allowed set, using the call-site-provided message.","triggerScenarios":"A statement validation passes a list of user identifiers/keywords that must all come from an allowed set (e.g. allowed options or clauses), and the user supplied something outside it.","commonSituations":"Using an unsupported option name in CREATE/ALTER statements, or a keyword not permitted in the given context; often caused by typos or by using syntax from a different Cassandra version.","solutions":["Compare each item in your list against the allowed elements implied by the error message or docs","Remove or rename the unsupported entry to one of the expected elements","Verify the option/keyword is supported in your Cassandra version"],"exampleFix":"// before\nCREATE TABLE ks.t (k int PRIMARY KEY, v int) WITH bad_option = 'x'; -- unsupported option\n// after\nCREATE TABLE ks.t (k int PRIMARY KEY, v int) WITH comment = 'x';","handlingStrategy":"validation","validationCode":"List<String> allowed = List.of(\"comment\", \"default_time_to_live\", \"gc_grace_seconds\");\nif (!allowed.containsAll(userOptions.keySet())) throw new IllegalArgumentException(\"unsupported option in \" + userOptions);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Whitelist allowed options/keywords in application code","Check feature availability for your Cassandra version before using new options"],"tags":["cql","validation","invalid-argument"],"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-17T15:17:12.973Z"}