{"record":{"id":"cb97e1250ff8ad8b","repo":"apache/cassandra","slug":"must-specify-at-least-one-command-with-a-non-zero-cb97e1","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/SettingsCommandUser.java","lineNumber":97,"sourceCode":"            \tyamlURI = URI.create(curYamlPath);\n            \tString uriScheme = yamlURI.getScheme();\n            \tif (uriScheme == null || \"file\".equals(uriScheme)) {\n                    throw new IllegalArgumentException(\"File '\" + yamlURI.getPath() + \"' doesn't exist!\");\n            \t}\n            }\n            StressProfile profile = StressProfile.load(yamlURI);\n            String specName = profile.specName;\n            if (default_profile_name == null) {default_profile_name=specName;} //first file is default\n            if (profiles.containsKey(specName))\n            {\n                throw new IllegalArgumentException(\"Must only specify a singe YAML file per table (including keyspace qualifier).\");\n            }\n            profiles.put(specName, profile);\n        }\n\n\n        if (ratios.size() == 0)\n            throw new IllegalArgumentException(\"Must specify at least one command with a non-zero ratio\");\n    }\n\n    public boolean hasInsertOnly()\n    {\n        return ratios.size() == 1 && ratios.containsKey(\"insert\");\n    }\n\n    public OpDistributionFactory getFactory(final StressSettings settings)\n    {\n        final SeedManager seeds = new SeedManager(settings);\n\n        final Map<String, TokenRangeIterator> tokenRangeIterators = new LinkedHashMap<>();\n        profiles.forEach((k,v)->tokenRangeIterators.put(k, (v.tokenRangeQueries.isEmpty()\n                                                            ? null\n                                                            : new TokenRangeIterator(settings,\n                                                                                     v.maybeLoadTokenRanges(settings)))));\n\n        return new SampledOpDistributionFactory<String>(ratios, clustering)","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/settings/SettingsCommandUser.java#L79-L115","documentation":"SettingsCommandUser aggregates op ratios across the loaded profiles; ops() expressions assign weights to named operations. After parsing profiles and ratios, the constructor requires that at least one operation has a non-zero ratio — this error means every supplied ops() weight was zero or no ops() entries resolved, so there would be no operations to run.","triggerScenarios":"Running 'cassandra-stress user profile=p.yaml ops(insert=0,read=0)' or ops names that don't match any operation defined in the YAML (so no ratios register), making ratios.size() == 0.","commonSituations":"Script-generated weights that evaluate to zero; op names mismatching the YAML-defined operation names (case/typo); forgetting the ops() argument entirely; multiplying weights by a config value that resolves to 0.","solutions":["Set at least one positive weight in ops(), e.g. ops(insert=3,read=1).","Ensure each ops() key matches an operation name defined in the profile YAML exactly.","Check your script/config isn't zeroing out all weights.","Run with 'cassandra-stress user profile=... ops(...)' including ops explicitly rather than relying on defaults."],"exampleFix":"// before\ncassandra-stress user profile=p.yaml ops(insert=0)\n// after\ncassandra-stress user profile=p.yaml ops(insert=1)","handlingStrategy":"validation","validationCode":"boolean anyPositive = opsWeights.values().stream().anyMatch(v -> v > 0);\nif (!anyPositive) throw new IllegalArgumentException(\"at least one ops() weight must be > 0\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass ops(name=positiveWeight) with names matching the YAML-defined operations.","Verify op names against the profile YAML before generating the command.","Guard scripts that compute weights against dividing/multiplying by zero."],"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"}