apache/cassandra · error · IllegalArgumentException

-schema can only be provided with predefined operations…

Error message

-schema can only be provided with predefined operations insert, read, etc.; the 'user' command requires a schema yaml instead

What it means

The 'user' command defines its schema in a profile YAML, so a -schema option on the command line is contradictory. SettingsSchema.get throws IllegalArgumentException whenever -schema appears together with a user command.

Solutions

  1. Remove the -schema option and define keyspace/table/replication inside the profile YAML instead
  2. Set the keyspace in the profile's keyspace spec, or pass only non-schema options like -rate, -log
  3. If you need -schema, switch to a predefined command (insert, read, mixed, counter_write, etc.)

Example fix

// before
cassandra-stress user profile=prof.yaml -schema replication(factor=3)
// after
cassandra-stress user profile=prof.yaml ops(insert=1)  # keyspace defined in prof.yaml
Defensive patterns

Strategy: validation

Validate before calling

boolean isUser = args.get(0).equals("user");
if (isUser && Arrays.asList(args).contains("-schema"))
    throw new IllegalArgumentException("drop -schema; define keyspace/table in the profile yaml");

Try / catch

try { StressSettings.get(parseMap(args)); } catch (IllegalArgumentException e) { if (e.getMessage().contains("-schema can only be provided with predefined")) args = removeOption(args, "-schema"); else throw e; }

Prevention

When it happens

Trigger: cassandra-stress user profile=profile.yaml -schema replication(...)... — supplying -schema to the user command in any form.

Common situations: Adapting an insert/read command line to a user profile and leaving the old -schema fragment in place; copied CI scripts.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

Thrown at tools/stress/src/org/apache/cassandra/stress/settings/SettingsSchema.java:243

    {
        out.println("  Keyspace: " + keyspace);
        out.println("  Replication Strategy: " + replicationStrategy);
        out.println("  Replication Strategy Options: " + replicationStrategyOptions);

        out.println("  Table Compression: " + compression);
        out.println("  Table Compaction Strategy: " + compactionStrategy);
        out.println("  Table Compaction Strategy Options: " + compactionStrategyOptions);
    }


    public static SettingsSchema get(Map<String, String[]> clArgs, SettingsCommand command)
    {
        String[] params = clArgs.remove("-schema");
        if (params == null)
            return new SettingsSchema(new Options(), command);

        if (command instanceof SettingsCommandUser)
            throw new IllegalArgumentException("-schema can only be provided with predefined operations insert, read, etc.; the 'user' command requires a schema yaml instead");

        GroupedOptions options = GroupedOptions.select(params, new Options());
        if (options == null)
        {
            printHelp();
            System.out.println("Invalid -schema options provided, see output for valid options");
            System.exit(1);
        }
        return new SettingsSchema((Options) options, command);
    }

    public static void printHelp()
    {
        GroupedOptions.printOptions(System.out, "-schema", new Options());
    }

    public static Runnable helpPrinter()
    {

View on GitHub (pinned to 88fd0f6a0e)