{"record":{"id":"4f28cc8e03113510","repo":"apache/cassandra","slug":"invalid-parameter-list-for-gaussian-distribution","errorCode":null,"errorMessage":"Invalid parameter list for gaussian distribution: ","messagePattern":"Invalid parameter list for gaussian distribution: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/settings/OptionDistribution.java","lineNumber":219,"sourceCode":"            case 'b':\n                multiplier *= 1000;\n            case 'm':\n                multiplier *= 1000;\n            case 'k':\n                multiplier *= 1000;\n                value = value.substring(0, value.length() - 1);\n        }\n        return Long.parseLong(value) * multiplier;\n    }\n\n    private static final class GaussianImpl implements Impl\n    {\n\n        @Override\n        public DistributionFactory getFactory(List<String> params)\n        {\n            if (params.size() > 3 || params.size() < 1)\n                throw new IllegalArgumentException(\"Invalid parameter list for gaussian distribution: \" + params);\n            try\n            {\n                String[] bounds = params.get(0).split(\"\\\\.\\\\.+\");\n                final long min = parseLong(bounds[0]);\n                final long max = parseLong(bounds[1]);\n                final double mean, stdev;\n                if (params.size() == 3)\n                {\n                    mean = Double.parseDouble(params.get(1));\n                    stdev = Double.parseDouble(params.get(2));\n                }\n                else\n                {\n                    final double stdevsToEdge = params.size() == 1 ? 3d : Double.parseDouble(params.get(1));\n                    mean = (min + max) / 2d;\n                    stdev = ((max - min) / 2d) / stdevsToEdge;\n                }\n                if (min == max)","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/settings/OptionDistribution.java#L201-L237","documentation":"In Apache Cassandra's cassandra-stress tool, OptionDistribution's GaussianImpl.getFactory() validates the argument count of a GAUSSIAN(...) distribution spec. It throws IllegalArgumentException when the parameter list has fewer than 1 or more than 3 entries. Valid forms are GAUSSIAN(min..max), GAUSSIAN(min..max,stdvrng) and GAUSSIAN(min..max,mean,stdev).","triggerScenarios":"Calling getFactory with an empty params list (e.g. 'gaussian()' or 'gauss' with no argument), or with 4+ comma-separated parameters (e.g. 'gaussian(1..1000,500,10,extra)').","commonSituations":"Typing extra commas in a cassandra-stress -pop or cl/spec option (e.g. 'GAUSSIAN(1..100,3,)'), passing an empty distribution spec from a script variable that expanded to nothing, or hand-editing a stress profile and leaving a trailing comma.","solutions":["Pass exactly 1, 2, or 3 parameters: GAUSSIAN(min..max), GAUSSIAN(min..max,stdvrng), or GAUSSIAN(min..max,mean,stdev).","Remove empty or trailing commas from the distribution spec (e.g. 'GAUSSIAN(1..1000,3,)' -> 'GAUSSIAN(1..1000,3)').","Check shell/script variable expansion is not producing an empty or duplicated argument inside the parentheses."],"exampleFix":"// before\ndist = GAUSSIAN(1..1000, 500, 100, 5)\n// after\ndist = GAUSSIAN(1..1000, 500, 100)","handlingStrategy":"validation","validationCode":"List<String> params = ...; // e.g. from GAUSSIAN(...)\nif (params.size() < 1 || params.size() > 3)\n    throw new IllegalArgumentException(\"GAUSSIAN expects 1-3 params: GAUSSIAN(min..max[,stdvrng|(mean,stdev)]), got \" + params);","typeGuard":null,"tryCatchPattern":"try {\n    DistributionFactory f = new OptionDistribution(\"\", \"\", false).getImpl(\"gaussian\").getFactory(params);\n} catch (IllegalArgumentException e) {\n    System.err.println(\"Bad distribution spec: \" + e.getMessage() + \" — see 'cassandra-stress help'\");\n}","preventionTips":["Validate parameter count against 1-3 before calling getFactory.","Keep the distribution spec on one shell-quoted token to avoid split artifacts.","Print OptionDistribution's multiLineDisplay() help when building specs programmatically."],"tags":["cassandra","cli","argument-count","distribution"],"backgroundTag":"invalid-cli-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"}