{"record":{"id":"5d2a38860e5cdcad","repo":"apache/cassandra","slug":"invalid-default-spec","errorCode":null,"errorMessage":"Invalid default spec: ","messagePattern":"Invalid default spec: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"tools/stress/src/org/apache/cassandra/stress/settings/OptionRatioDistribution.java","lineNumber":92,"sourceCode":"    }\n\n    public static RatioDistributionFactory get(String spec)\n    {\n        OptionRatioDistribution opt = new OptionRatioDistribution(\"\", \"\", \"\", true);\n        if (!opt.accept(spec))\n            throw new IllegalArgumentException(\"Invalid ratio definition: \"+spec);\n        return opt.get();\n    }\n\n    public RatioDistributionFactory get()\n    {\n        if (delegate.setByUser())\n            return new DelegateFactory(delegate.get(), divisor);\n        if (defaultSpec == null)\n            return null;\n        OptionRatioDistribution sub = new OptionRatioDistribution(\"\", null, null, true);\n        if (!sub.accept(defaultSpec))\n            throw new IllegalStateException(\"Invalid default spec: \" + defaultSpec);\n        return sub.get();\n    }\n\n    @Override\n    public boolean happy()\n    {\n        return delegate.happy();\n    }\n\n    public String longDisplay()\n    {\n        return delegate.longDisplay();\n    }\n\n    @Override\n    public List<String> multiLineDisplay()\n    {\n        return Arrays.asList(","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/tools/stress/src/org/apache/cassandra/stress/settings/OptionRatioDistribution.java#L74-L110","documentation":"OptionRatioDistribution is a cassandra-stress CLI option that defines a ratio between two quantities (e.g. column size vs count). When no user value was supplied, it falls back to a default spec string by parsing it with a fresh sub-option; this error means the default spec string failed to parse, so the option cannot produce any value.","triggerScenarios":"Calling get() (via apply()) on an OptionRatioDistribution where delegate.setByUser() is false, defaultSpec != null, and the internal sub-option's accept(defaultSpec) returns false — i.e. the hardcoded or programmatically passed default spec string does not match the expected '<dividend>/<divisor>' ratio format.","commonSituations":"A developer embedding cassandra-stress settings programmatically passes a malformed default like '1.5' or 'n/2' instead of a numeric ratio like '1/10'; a typo in a wrapper script that constructs the default spec; a refactoring changed the accepted pattern but not the default string.","solutions":["Fix the default spec string to be a valid ratio of the form '<number>/<number>', e.g. \"1/4\".","Print the offending spec (it is included in the exception message) and validate it against the ratio pattern before passing it in.","Pass the ratio explicitly on the command line so delegate.setByUser() is true and the default path is never taken.","If you don't need a default, pass null as defaultSpec so get() returns null instead of parsing."],"exampleFix":"// before\nOptionRatioDistribution opt = new OptionRatioDistribution(\"size\", null, \"one tenth\", false);\n// after\nOptionRatioDistribution opt = new OptionRatioDistribution(\"size\", null, \"1/10\", false);","handlingStrategy":"validation","validationCode":"if (defaultSpec != null && !defaultSpec.matches(\"\\\\d+(\\.\\\\d+)?/\\\\d+(\\.\\\\d+)?\")) throw new IllegalArgumentException(\"bad ratio default: \" + defaultSpec);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always express ratio defaults as 'numerator/denominator' strings.","Unit-test option defaults by calling get() in a fresh settings instance.","Pass null defaultSpec when no default is needed."],"tags":["cli","configuration","validation"],"backgroundTag":"invalid-config-value","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"}