{"record":{"id":"5b2b88a44d98c4c2","repo":"apache/cassandra","slug":"invalid-option-combination-can-not-provide-tokens","errorCode":null,"errorMessage":"Invalid option combination: Can not provide tokens when using user-defined","messagePattern":"Invalid option combination: Can not provide tokens when using user-defined","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/Compact.java","lineNumber":78,"sourceCode":"            names = {\"-j\", \"--jobs\"},\n            description = \"Use -j to specify the maximum number of threads to use for parallel compaction. \" +\n                          \"If not set, up to half the compaction threads will be used. \" +\n                          \"If set to 0, the major compaction will use all threads and will not permit other compactions to run until it completes (use with caution).\")\n    private Integer parallelism = null;\n\n    @Override\n    public void execute(NodeProbe probe)\n    {\n        final boolean startEndTokenProvided = !(startToken.isEmpty() && endToken.isEmpty());\n        final boolean partitionKeyProvided = !partitionKey.isEmpty();\n        final boolean tokenProvided = startEndTokenProvided || partitionKeyProvided;\n        if (splitOutput && (userDefined || tokenProvided))\n        {\n            throw new RuntimeException(\"Invalid option combination: Can not use split-output here\");\n        }\n        if (userDefined && tokenProvided)\n        {\n            throw new RuntimeException(\"Invalid option combination: Can not provide tokens when using user-defined\");\n        }\n\n        if (userDefined)\n        {\n            try\n            {\n                String userDefinedFiles = String.join(\",\", args);\n                probe.forceUserDefinedCompaction(userDefinedFiles);\n            } catch (Exception e) {\n                throw new RuntimeException(\"Error occurred during user defined compaction\", e);\n            }\n            return;\n        }\n\n        List<String> keyspaces = parseOptionalKeyspace(args, probe);\n        String[] tableNames = parseOptionalTables(args);\n\n        for (String keyspace : keyspaces)","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/Compact.java#L60-L96","documentation":"Nodetool Compact rejects combining --user-defined with token-based options (--start-token/--end-token) or --partition-key; user-defined compaction takes raw SSTable file arguments only. Thrown locally before any JMX call.","triggerScenarios":"Passing `--user-defined` along with --start-token/--end-token or --partition-key in one `nodetool compact` invocation.","commonSituations":"Copy-pasting flags from two different compaction recipes; misunderstanding that user-defined selects files, not ranges.","solutions":["Remove the token/partition-key arguments when using --user-defined.","Or remove --user-defined and keep the range/partition specification.","Choose one compaction strategy per invocation."],"exampleFix":"// before\nnodetool compact --user-defined --partition-key ks:tbl:key ks\n// after\nnodetool compact --user-defined ks tbl data-ka-1-Data.db","handlingStrategy":"validation","validationCode":"boolean tokenProvided = !(startToken.isEmpty() && endToken.isEmpty()) || !partitionKey.isEmpty();\nif (userDefined && tokenProvided)\n    throw new IllegalArgumentException(\"--user-defined accepts only SSTable file arguments, not tokens/partition keys\");","typeGuard":null,"tryCatchPattern":"try { executeCompaction(...); }\ncatch (RuntimeException e) { if (e.getMessage().startsWith(\"Invalid option combination\")) { printUsage(); System.exit(2); } throw e; }","preventionTips":["Use --user-defined only with SSTable file arguments.","Use --start-token/--end-token/--partition-key only in normal compaction mode.","Document one mode per compaction invocation in runbooks.","Validate flag combinations in CI for operational scripts."],"tags":["nodetool","cli","compaction","options"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}