apache/cassandra · error · InvalidRequestException

message (caller-provided message string, checkContainsOnly)

Error message

message (caller-provided message string, checkContainsOnly)

What it means

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.

Solutions

  1. Compare each item in your list against the allowed elements implied by the error message or docs
  2. Remove or rename the unsupported entry to one of the expected elements
  3. Verify the option/keyword is supported in your Cassandra version

Example fix

// before
CREATE TABLE ks.t (k int PRIMARY KEY, v int) WITH bad_option = 'x'; -- unsupported option
// after
CREATE TABLE ks.t (k int PRIMARY KEY, v int) WITH comment = 'x';
Defensive patterns

Strategy: validation

Validate before calling

List<String> allowed = List.of("comment", "default_time_to_live", "gc_grace_seconds");
if (!allowed.containsAll(userOptions.keySet())) throw new IllegalArgumentException("unsupported option in " + userOptions);

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/b1b6962a759fec10. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/cql3/statements/RequestValidations.java:189

            throw invalidRequest(message);
    }

    /**
     * Checks that the specified list contains only the specified elements.
     *
     * @param list the list to test
     * @param expectedElements the expected elements
     * @param message the error message
     * @throws InvalidRequestException if the specified list contains duplicates.
     */
    public static <E> void checkContainsOnly(List<E> list,
                                             List<E> expectedElements,
                                             String message) throws InvalidRequestException
    {
        List<E> copy = new ArrayList<>(list);
        copy.removeAll(expectedElements);
        if (!copy.isEmpty())
            throw invalidRequest(message);
    }

    /**
     * Checks that the specified expression is {@code false}. 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>true</code>.
     */
    public static void checkFalse(boolean expression,
                                  String messageTemplate,
                                  Object messageArg) throws InvalidRequestException
    {
        checkTrue(!expression, messageTemplate, messageArg);
    }

View on GitHub (pinned to 88fd0f6a0e)