apache/cassandra · error · IllegalArgumentException

is not a valid type

Error message

 is not a valid type

What it means

SettingsColumn parses the comparator string (e.g. 'UTF8Type' or 'IntegerType') with Cassandra's TypeParser to build an AbstractType. If TypeParser cannot resolve the string to a known type, the SettingsColumn constructor wraps the failure in this IllegalArgumentException, discarding the underlying cause.

Solutions

  1. Use the exact AbstractType class name, e.g. -col comparator=UTF8Type (not 'UTF8' or 'text').
  2. Test the type string with TypeParser or against the list of built-in types (AsciiType, UTF8Type, IntegerType, TimeUUIDType, etc.).
  3. Fix composite syntax, e.g. comparator=CompositeType(UTF8Type, Int32Type).
  4. If using a custom type, ensure the class is on the cassandra-stress classpath.

Example fix

// before
cassandra-stress write n=1M -col comparator=text
// after
cassandra-stress write n=1M -col comparator=UTF8Type
Defensive patterns

Strategy: validation

Validate before calling

try { TypeParser.parse(comparatorStr); } catch (Exception e) { throw new IllegalArgumentException("invalid comparator: " + comparatorStr, e); }

Try / catch

try { /* build column settings */ } catch (IllegalArgumentException e) { if (e.getMessage().endsWith("is not a valid type")) { System.err.println("Use e.g. UTF8Type, Int32Type, or CompositeType(...)"); } throw e; }

Prevention

When it happens

Trigger: Running cassandra-stress with -col comparator=<value> where the value is not a parseable Cassandra type name — e.g. a typo like 'Utf8' instead of 'UTF8Type', a fully-qualified class that isn't on the classpath, or an invalid composite type expression.

Common situations: Confusing CQL type names (text, int) with the comparator AbstractType names (UTF8Type, Int32Type); copying a type alias unsupported by the stress tool version; malformed nested/composite type syntax like 'CompositeType(utf8' missing a closing paren.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/4f8257c918bbd9bf. Report an issue: GitHub.

Appendix: source

Thrown at tools/stress/src/org/apache/cassandra/stress/settings/SettingsColumn.java:105

            }

            if (!(parsed instanceof TimeUUIDType || parsed instanceof AsciiType || parsed instanceof UTF8Type))
            {
                System.err.println("Currently supported types are: TimeUUIDType, AsciiType, UTF8Type.");
                System.exit(1);
            }
        }
        if (name != null)
        {
            assert count == null;

            AbstractType comparator;
            try
            {
                comparator = TypeParser.parse(this.comparator);
            } catch (Exception e)
            {
                throw new IllegalArgumentException(this.comparator + " is not a valid type");
            }

            final String[] names = name.name.value().split(",");
            this.names = new ArrayList<>(names.length);

            for (String columnName : names)
                this.names.add(comparator.fromString(columnName));
            Collections.sort(this.names, BytesType.instance);
            this.namestrs = new ArrayList<>();
            for (ByteBuffer columnName : this.names)
                this.namestrs.add(comparator.getString(columnName));

            final int nameCount = this.names.size();
            countDistribution = new DistributionFactory()
            {
                @Override
                public Distribution get()
                {

View on GitHub (pinned to 88fd0f6a0e)