{"record":{"id":"9ed08167d950856d","repo":"apache/cassandra","slug":"illegal-distribution-specification","errorCode":null,"errorMessage":"Illegal distribution specification: ","messagePattern":"Illegal distribution specification: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/settings/OptionDistribution.java","lineNumber":100,"sourceCode":"        this.defaultSpec = defaultSpec;\n        this.description = description;\n        this.required = required;\n    }\n\n    @Override\n    public boolean accept(String param)\n    {\n        if (!toLowerCaseLocalized(param).startsWith(prefix))\n            return false;\n        spec = param.substring(prefix.length());\n        return true;\n    }\n\n    public static DistributionFactory get(String spec)\n    {\n        Matcher m = FULL.matcher(spec);\n        if (!m.matches())\n            throw new IllegalArgumentException(\"Illegal distribution specification: \" + spec);\n        boolean inverse = m.group(1).equals(\"~\");\n        String name = m.group(2);\n        Impl impl = LOOKUP.get(toLowerCaseLocalized(name));\n        if (impl == null)\n            throw new IllegalArgumentException(\"Illegal distribution type: \" + name);\n        List<String> params = new ArrayList<>();\n        m = ARGS.matcher(m.group(3));\n        while (m.find())\n            params.add(m.group());\n        DistributionFactory factory = impl.getFactory(params);\n        return inverse ? new InverseFactory(factory) : factory;\n    }\n\n    public DistributionFactory get()\n    {\n        return spec != null ? get(spec) : defaultSpec != null ? get(defaultSpec) : null;\n    }\n","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/settings/OptionDistribution.java#L82-L118","documentation":"OptionDistribution.get parses a distribution spec string like gaussian(1..100) or ~uniform(...). The spec must match the FULL pattern (optional '~' inverse prefix, distribution name, parenthesized args); otherwise no legal parse exists and it throws IllegalArgumentException 'Illegal distribution specification: <spec>'.","triggerScenarios":"Supplying a distribution option (e.g. -pop, lookback=, revisit=, visit=) whose string does not match name(args) syntax — e.g. 'uniform', 'uniform(1..100)extra', 'gausian(1..10)' with a malformed shape, or empty args.","commonSituations":"Missing parentheses in distribution specs; stray characters from shell quoting; forgetting the argument list entirely; typo in the overall spec format.","solutions":["Use the form name(arg,arg,...), e.g. uniform(1..1000) or gaussian(50..100)","Prefix with ~ only for inverse distributions, e.g. ~uniform(1..100)","Run the stress command help to list supported distribution formats"],"exampleFix":"// before\n-pop uniform\n// after\n-pop uniform(1..1000000)","handlingStrategy":"validation","validationCode":"Pattern FULL = Pattern.compile(\"(~?)(\\w+)\\((.*)\\)\");\nif (!FULL.matcher(spec).matches()) throw new IllegalArgumentException(\"Illegal distribution spec: \" + spec);","typeGuard":"boolean isValidDistSpec(String s) { return s != null && s.matches(\"~?\\w+\\(.*\\)\"); }","tryCatchPattern":"try { DistributionFactory f = OptionDistribution.get(spec); } catch (IllegalArgumentException e) { log.error(\"Distribution '{}' must match name(args), e.g. uniform(1..1000)\", spec); }","preventionTips":["Always write distributions as name(args)","Use ~ prefix only for inverse distributions","Test distribution specs with a small stress run before large jobs"],"tags":["cli","distribution","argument-parsing"],"backgroundTag":"invalid-argument-format","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"}