apache/cassandra · error · SyntaxException
is not a collection type
Error message
%s is not a collection type
What it means
Inside TypeParser.getCollectionsParameters() (used to parse DynamicCompositeType-style hex-keyed collection arguments), each parsed type must be a CollectionType (map, set, or list). This SyntaxException is thrown when a value type resolves to a non-collection AbstractType, e.g. a plain comparator like UTF8Type or Int32Type.
Solutions
- Use a collection type after the colon, e.g. MapType.getInstance(TypeParser) form: replace UTF8Type with ListType(UTF8Type), SetType(Int32Type) or MapType(UTF8Type, Int32Type)
- Check the message's leading type name to see which non-collection type was rejected and why it appeared
- Verify the intent: if the field is not meant to hold collections, don't use getCollectionsParameters/DynamicCompositeType at all — use CompositeType
- Consult the schema docs for DynamicCompositeType: every aliased value must be a collection type
Example fix
// before
TypeParser.parse("DynamicCompositeType(a => Int32Type)");
// after
TypeParser.parse("DynamicCompositeType(a => ListType(Int32Type))"); Defensive patterns
Strategy: type-guard
Validate before calling
static boolean valuesAreCollectionTypes(Collection<AbstractType<?>> types) {
return types.stream().allMatch(t -> t instanceof CollectionType);
} Type guard
static boolean isCollectionType(AbstractType<?> t) {
return t instanceof CollectionType; // MapType, SetType, ListType
} Try / catch
try {
AbstractType<?> t = TypeParser.parse(dynamicCompositeString);
} catch (SyntaxException e) {
if (e.getMessage().contains("is not a collection type"))
throw new SchemaConfigurationException("DynamicCompositeType values must be map/set/list types", e);
throw e;
} Prevention
- In DynamicCompositeType alias maps, only use ListType/SetType/MapType as values
- Read the rejected type name from the message to identify the offending entry
- If you need scalars, use CompositeType rather than DynamicCompositeType
When it happens
Trigger: Parsing a collections parameter string where a value after '<hexkey>:' parses to a non-collection type, e.g. a parameter string like "(6b6579:UTF8Type)" passed through getCollectionsParameters() — only map/set/list types are accepted after the colon.
Common situations: Developers defining DynamicCompositeType parameters who supply a scalar comparator where only ListType/SetType/MapType is allowed, copy-pasting comparator names between type families, or constructing the parameter map programmatically with the wrong AbstractType subclass.
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
- FrozenType() only accepts one parameter
- Invalid comparator class
- MapType takes exactly 2 type parameters
- ReversedType takes exactly one argument, " + types.size() +…
- is reserved for internal functionality
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/969653d491603add.
Report an issue: GitHub.
Appendix: source
Thrown at src/java/org/apache/cassandra/db/marshal/TypeParser.java:381
if (str.charAt(idx) == ')')
{
++idx;
return map;
}
ByteBuffer bb = fromHex(readNextIdentifier());
skipBlank();
if (str.charAt(idx) != ':')
throwSyntaxError("expecting ':' token");
++idx;
skipBlank();
try
{
AbstractType<?> type = parse();
if (!(type instanceof CollectionType))
throw new SyntaxException(type + " is not a collection type");
map.put(bb, (CollectionType)type);
}
catch (SyntaxException e)
{
SyntaxException ex = new SyntaxException(String.format("Exception while parsing '%s' around char %d", str, idx));
ex.initCause(e);
throw ex;
}
}
throw new SyntaxException(String.format("Syntax error parsing '%s' at char %d: unexpected end of string", str, idx));
}
private ByteBuffer fromHex(String hex) throws SyntaxException
{
try
{
return ByteBufferUtil.hexToBytes(hex);
}View on GitHub (pinned to 88fd0f6a0e)