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
- Fix the type declaration to contain exactly one element type: list<int>, list<text>, etc.
- Validate type strings before applying schema changes.
- 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
- Double-check type declarations: list has one parameter, map has two, set has one.
- Catch ConfigurationException when parsing user-supplied type strings.
- Lint dynamically generated type strings in tests.
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
- MapType takes exactly 2 type parameters
- ReversedType takes exactly one argument, " + types.size() +
- SetType takes exactly 1 type parameter
- Syntax error parsing '%s: for msg unexpected character '%s'
- The result of ICompressor.serializedAs(), %s, of a compresso
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/9d72d038eb5ce749.
Report an issue: GitHub.