apache/cassandra · error · IllegalStateException
Invalid default spec:
Error message
Invalid default spec:
What it means
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.
Source
Thrown at tools/stress/src/org/apache/cassandra/stress/settings/OptionRatioDistribution.java:92
}
public static RatioDistributionFactory get(String spec)
{
OptionRatioDistribution opt = new OptionRatioDistribution("", "", "", true);
if (!opt.accept(spec))
throw new IllegalArgumentException("Invalid ratio definition: "+spec);
return opt.get();
}
public RatioDistributionFactory get()
{
if (delegate.setByUser())
return new DelegateFactory(delegate.get(), divisor);
if (defaultSpec == null)
return null;
OptionRatioDistribution sub = new OptionRatioDistribution("", null, null, true);
if (!sub.accept(defaultSpec))
throw new IllegalStateException("Invalid default spec: " + defaultSpec);
return sub.get();
}
@Override
public boolean happy()
{
return delegate.happy();
}
public String longDisplay()
{
return delegate.longDisplay();
}
@Override
public List<String> multiLineDisplay()
{
return Arrays.asList(View on GitHub (pinned to 88fd0f6a0e)
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.
Example fix
// before
OptionRatioDistribution opt = new OptionRatioDistribution("size", null, "one tenth", false);
// after
OptionRatioDistribution opt = new OptionRatioDistribution("size", null, "1/10", false); Defensive patterns
Strategy: validation
Validate before calling
if (defaultSpec != null && !defaultSpec.matches("\\d+(\.\\d+)?/\\d+(\.\\d+)?")) throw new IllegalArgumentException("bad ratio default: " + defaultSpec); Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- You need to state at least one --target host to replay the q
- Must specify at least one command with a non-zero ratio
- Must specify at least one command with a non-zero ratio
- Invalid data rate: value must be non-negative
- Invalid data storage: %s Accepted units:%s
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/5d2a38860e5cdcad.
Report an issue: GitHub.