apache/cassandra · error · InvalidRequestException

message (caller-provided message string…

Error message

message (caller-provided message string, checkContainsNoDuplicates)

What it means

RequestValidations.checkContainsNoDuplicates(List<?> list, String message) throws InvalidRequestException if the list contains duplicate elements (detected by comparing HashSet size to list size). Used during CQL statement validation to reject duplicate identifiers in user-supplied lists.

Solutions

  1. Remove duplicate entries from the offending identifier list in the query
  2. If generated dynamically, deduplicate the list before building the statement
  3. Check for case variations that normalize to the same identifier (unquoted names are lowercased)

Example fix

// before
SELECT a, b, a FROM ks.t WHERE ...; -- duplicate 'a'
// after
SELECT a, b FROM ks.t WHERE ...;
Defensive patterns

Strategy: validation

Validate before calling

Set<String> seen = new HashSet<>();
for (String col : columns) { if (!seen.add(col.toLowerCase())) throw new IllegalArgumentException("duplicate column " + col); }

Prevention

When it happens

Trigger: Any statement whose validation passes a user-supplied list (e.g. column names in a restriction, selection, or definition) that contains the same element more than once, with a call-site-provided message.

Common situations: Listing the same column twice in a clause, e.g. duplicate column in SELECT restrictions, PRIMARY KEY definitions, or CREATE statements with repeated identifiers.

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/3f143a9948eb2f91. Report an issue: GitHub.

Appendix: source

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

                                                               Object arg1,
                                                               Object arg2)
                                                               throws InvalidRequestException
    {
        checkTrue(!collection.isEmpty(), messageTemplate, arg1, arg2);
        return collection;
    }

    /**
     * Checks that the specified list does not contains duplicates.
     *
     * @param list the list to test
     * @param message the error message
     * @throws InvalidRequestException if the specified list contains duplicates.
     */
    public static void checkContainsNoDuplicates(List<?> list, String message) throws InvalidRequestException
    {
        if (new HashSet<>(list).size() != list.size())
            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);

View on GitHub (pinned to 88fd0f6a0e)