{"record":{"id":"dc3909f3fc54d454","repo":"apache/cassandra","slug":"must-specify-at-least-one-command-with-a-non-zero","errorCode":null,"errorMessage":"Must specify at least one command with a non-zero ratio","messagePattern":"Must specify at least one command with a non-zero ratio","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefinedMixed.java","lineNumber":56,"sourceCode":"\n// Settings unique to the mixed command type\npublic class SettingsCommandPreDefinedMixed extends SettingsCommandPreDefined\n{\n\n    // Ratios for selecting commands - index for each Command, NaN indicates the command is not requested\n    private final Map<Command, Double> ratios;\n    private final DistributionFactory clustering;\n    private final Options options;\n\n    public SettingsCommandPreDefinedMixed(Options options)\n    {\n        super(Command.MIXED, options);\n\n        clustering = options.clustering.get();\n        ratios = options.probabilities.ratios();\n        this.options = options;\n        if (ratios.size() == 0)\n            throw new IllegalArgumentException(\"Must specify at least one command with a non-zero ratio\");\n    }\n\n    public OpDistributionFactory getFactory(final StressSettings settings)\n    {\n        final SeedManager seeds = new SeedManager(settings);\n        return new SampledOpDistributionFactory<Command>(ratios, clustering)\n        {\n            protected List<? extends Operation> get(Timer timer, Command key, boolean isWarmup)\n            {\n                return Collections.singletonList(PredefinedOperation.operation(key, timer, SettingsCommandPreDefinedMixed.this.newGenerator(settings), seeds, settings, add));\n            }\n        };\n    }\n\n    // Option Declarations\n\n    static class Options extends SettingsCommandPreDefined.Options\n    {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandPreDefinedMixed.java#L38-L74","documentation":"SettingsCommandPreDefinedMixed implements the 'mixed' predefined command, where each sub-command (read/write/insert/etc.) is assigned a probability ratio via the 'profile'/'ratio' style options. The constructor validates that the resulting ratio map is non-empty; this error means every command's ratio was zero or unset, leaving no operations to distribute.","triggerScenarios":"Running 'cassandra-stress mixed' where all supplied command ratios resolve to zero or none are supplied at all, causing options.probabilities.ratios() to return an empty map.","commonSituations":"Supplying only zero ratios like 'mixed ratio@media=0'; misspelling the ratio option so it's ignored; a script generating ratios that evaluates to all zeros; forgetting the ratio syntax entirely.","solutions":["Give at least one command a positive ratio, e.g. 'mixed ratio@read=3,ratio@write=1'.","Check for typos in ratio keys — they must match known command names (read, write, insert, counter_read, counter_write).","Ensure ratio values are positive numbers, not 0.","Print/echo the constructed option string in your script to verify ratios survive parameterization."],"exampleFix":"// before\ncassandra-stress mixed ratio@read=0,ratio@write=0\n// after\ncassandra-stress mixed ratio@read=1,ratio@write=1","handlingStrategy":"validation","validationCode":"boolean anyPositive = ratios != null && ratios.values().stream().anyMatch(v -> v > 0);\nif (!anyPositive) throw new IllegalArgumentException(\"at least one command ratio must be > 0\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include at least one ratio@<cmd>=<positive> when using mixed.","Assert generated option strings contain a positive ratio before execution.","Beware keys that silently fail to match, dropping ratios."],"tags":["cli","configuration","validation"],"backgroundTag":"missing-required-argument","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}