apache/cassandra · error · IllegalStateException
%s is expecting %d argument values. Getting %d instead.
Error message
%s is expecting %d argument values. Getting %d instead.
What it means
Before invoking a guardrail setter, the command validates that the number of provided value arguments equals the setter's parameter count; a mismatch throws IllegalStateException '<setter> is expecting <n> argument values. Getting <m> instead.'
Source
Thrown at src/java/org/apache/cassandra/tools/nodetool/GuardrailsConfigCommand.java:283
if (parameterTypes.length == 1 && parameterTypes[0] == Set.class)
{
if (args.size() > 2)
{
String guardrail = args.get(0);
// replace multiple arguments with one which is separated by a single comma
String collectedArguments = String.join(",", args.subList(1, args.size()));
args.clear();
args.add(guardrail);
args.add(collectedArguments);
}
}
}
private void validateArguments(Method setter, String setterName, List<String> args)
{
if (args.size() != setter.getParameterCount() + 1)
{
throw new IllegalStateException(format("%s is expecting %d argument values. Getting %d instead.",
setterName,
setter.getParameterCount(),
args.size() - 1));
}
}
private Object[] prepareArguments(List<String> args, Method method)
{
Class<?>[] parameterTypes = method.getParameterTypes();
Object[] arguments = new Object[args.size()];
for (int i = 0; i < args.size(); i++)
arguments[i] = castType(parameterTypes[i], args.get(i));
if (method.getName().endsWith("Threshold"))
{
List<Object> thresholdArgs = Arrays.asList(arguments);
Collections.reverse(thresholdArgs);View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Count the setter's expected parameters and supply exactly that many values after the guardrail name.
- Check `nodetool help guardrails-config` or docs for the guardrail's arity.
- For map/set guardrails, provide key and value pairs as separate arguments.
Example fix
// before nodetool guardrailsconfig set partition_size_guardrail_warn 10MB // after nodetool guardrailsconfig set partition_size_guardrail_warn 10MB 100MB
Defensive patterns
Strategy: validation
Validate before calling
ARITY = {'read_consistency_level': 1, 'partition_size_guardrail_warn': 2}
def validate_arity(name, values):
expected = ARITY.get(name)
if expected is not None and len(values) != expected:
raise SystemExit(f'{name} expects {expected} value(s), got {len(values)}') Prevention
- Look up each guardrail's parameter count before calling set.
- Provide multi-parameter guardrail values as separate arguments.
When it happens
Trigger: Running `nodetool guardrailsconfig set <name> v1 v2` for a single-parameter setter, or omitting values for a multi-parameter setter (e.g. map/two-threshold guardrails needing 2+ values).
Common situations: Two-parameter guardrails like minimum/maximum thresholds given only one value; accidentally pasting extra values; map-valued guardrails given one key without a value.
Related errors
- Do not specify additional arguments when --category/-c is se
- Guardrail %s not found.
- Unhandled return type:
- No arguments.
- Error occured when setting the config for setter %s with arg
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/8f7ba6265ea6da24.
Report an issue: GitHub.