apache/cassandra · error · ConfigurationException
SetType takes exactly 1 type parameter
Error message
SetType takes exactly 1 type parameter
What it means
SetType.getInstance(TypeParser) constructs a SetType from parsed type parameters, e.g. set<element_type>. It throws ConfigurationException when the parser does not provide exactly one type parameter, because a set needs exactly one element type.
Source
Thrown at src/java/org/apache/cassandra/db/marshal/SetType.java:61
import org.apache.cassandra.utils.JsonUtils;
import org.apache.cassandra.utils.bytecomparable.ByteComparable;
import org.apache.cassandra.utils.bytecomparable.ByteSource;
public class SetType<T> extends CollectionType<Set<T>>
{
// interning instances
private static final ConcurrentHashMap<AbstractType<?>, SetType> instances = new ConcurrentHashMap<>();
private static final ConcurrentHashMap<AbstractType<?>, SetType> frozenInstances = new ConcurrentHashMap<>();
private final AbstractType<T> elements;
private final SetSerializer<T> serializer;
private final boolean isMultiCell;
public static SetType<?> getInstance(TypeParser parser) throws ConfigurationException, SyntaxException
{
List<AbstractType<?>> l = parser.getTypeParameters();
if (l.size() != 1)
throw new ConfigurationException("SetType takes exactly 1 type parameter");
return getInstance(l.get(0).freeze(), true);
}
public static <T> SetType<T> getInstance(AbstractType<T> elements, boolean isMultiCell)
{
ConcurrentHashMap<AbstractType<?>, SetType> internMap = isMultiCell ? instances : frozenInstances;
SetType<T> t = internMap.get(elements);
return null == t
? internMap.computeIfAbsent(elements, k -> new SetType<>(k, isMultiCell))
: t;
}
public SetType(AbstractType<T> elements, boolean isMultiCell)
{
super(ComparisonType.CUSTOM, Kind.SET);
this.elements = elements;
this.serializer = SetSerializer.getInstance(elements.getSerializer(), elements.comparatorSet);View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Supply exactly one element type: e.g. set<org.apache.cassandra.db.marshal.Int32Type>.
- If two element types were intended, use map<k,v> instead of set.
- Catch ConfigurationException around TypeParser.parse()/getInstance and validate the type string before use.
Example fix
// before
TypeParser.parse("SetType(Int32Type, UTF8Type)");
// after
TypeParser.parse("SetType(Int32Type)"); Defensive patterns
Strategy: validation
Validate before calling
List<AbstractType<?>> params = parser.getTypeParameters();
if (params.size() != 1)
throw new ConfigurationException("set type requires exactly 1 parameter, got " + params.size()); Try / catch
try {
SetType<?> st = SetType.getInstance(parser);
} catch (ConfigurationException e) {
// report malformed set type definition
} catch (SyntaxException e) {
// report unparseable type string
} Prevention
- Write set types with one parameter: set<T>; two parameters means map<k,v>
- Validate user-supplied type strings before parsing
- Use server-generated comparator strings as reference
When it happens
Trigger: Parsing a type string like 'org.apache.cassandra.db.marshal.SetType' with zero parameters or with two or more parameters (e.g. set<int, text>) into SetType.getInstance(parser).
Common situations: Malformed schema definitions with extra type arguments; confusing set with map syntax (map takes 2 parameters, set takes 1); programmatic type parsing of user-supplied strings.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- MapType takes exactly 2 type parameters
- ReversedType takes exactly one argument, " + types.size() +
- Load CIDR groups cache operation not supported by %s
- Unsupported parameter '%s' for %s, supported parameters are
- JAAS login configuration missing for JMX authenticator setup
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/3e06087e4035f14d.
Report an issue: GitHub.