apache/cassandra · error · ConfigurationException

ListType takes exactly 1 type parameter

Error message

ListType takes exactly 1 type parameter

What it means

ListType.getInstance(TypeParser) builds a ListType from parsed type parameters. A list type requires exactly one element type parameter (e.g. list<int>); supplying zero or multiple parameters is invalid and throws ConfigurationException.

Source

Thrown at src/java/org/apache/cassandra/db/marshal/ListType.java:62

import org.apache.cassandra.utils.bytecomparable.ByteSource;

import static org.apache.cassandra.cql3.statements.RequestValidations.checkFalse;

public class ListType<T> extends CollectionType<List<T>>
{
    // interning instances
    private static final ConcurrentHashMap<AbstractType<?>, ListType> instances = new ConcurrentHashMap<>();
    private static final ConcurrentHashMap<AbstractType<?>, ListType> frozenInstances = new ConcurrentHashMap<>();

    private final AbstractType<T> elements;
    private final ListSerializer<T> serializer;
    private final boolean isMultiCell;

    public static ListType<?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
    {
        List<AbstractType<?>> l = parser.getTypeParameters();
        if (l.size() != 1)
            throw new ConfigurationException("ListType takes exactly 1 type parameter");

        return getInstance(l.get(0).freeze(), true);
    }

    public static <T> ListType<T> getInstance(AbstractType<T> elements, boolean isMultiCell)
    {
        ConcurrentHashMap<AbstractType<?>, ListType> internMap = isMultiCell ? instances : frozenInstances;
        ListType<T> t = internMap.get(elements);
        return null == t
             ? internMap.computeIfAbsent(elements, k -> new ListType<>(k, isMultiCell))
             : t;
    }

    private ListType(AbstractType<T> elements, boolean isMultiCell)
    {
        super(ComparisonType.CUSTOM, Kind.LIST);
        this.elements = elements;
        this.serializer = ListSerializer.getInstance(elements.getSerializer());

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Fix the type declaration to contain exactly one element type: list<int>, list<text>, etc.
  2. Validate type strings before applying schema changes.
  3. If a key-value collection was intended, use map<k,v> or set<t> instead.

Example fix

// before
CREATE TABLE t (tags list<text, int> PRIMARY KEY ...);
// after
CREATE TABLE t (tags list<text> PRIMARY KEY ...);
Defensive patterns

Strategy: validation

Validate before calling

List<AbstractType<?>> params = parser.getTypeParameters();
if (params.size() != 1) throw new IllegalArgumentException("list<T> requires exactly one type parameter");

Try / catch

try { type = ListType.getInstance(parser); } catch (ConfigurationException e) { throw new SchemaException("Bad list declaration: " + e.getMessage()); }

Prevention

When it happens

Trigger: Declaring or parsing a type string like 'list<>' or 'list<int,int>' via TypeParser; programmatic parser misuse passing a parameter list whose size != 1.

Common situations: Typoed CQL schema definitions; dynamically generated type strings built incorrectly; copy/paste from multi-argument types like map<k,v> into a list definition.

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/9d72d038eb5ce749. Report an issue: GitHub.