apache/cassandra · error · IllegalArgumentException
Format must be one of %s
Error message
Format must be one of %s
What it means
AsyncProfilerService.parseFormat validates the user-supplied profiling output format against the known AsyncProfilerFormat enum values. When the raw format string does not match any enum constant, valueOf throws IllegalArgumentException and the service re-throws with a message listing all valid formats. It guards the 'format' start parameter of the async-profiler MBean API.
Source
Thrown at src/java/org/apache/cassandra/service/AsyncProfilerService.java:204
}
}
public enum AsyncProfilerFormat
{
flat, traces, collapsed, flamegraph, tree, jfr;
public static String parseFormat(String rawFormat)
{
if (rawFormat == null || rawFormat.isBlank())
throw new IllegalArgumentException("Event can not be null nor blank string.");
try
{
return AsyncProfilerFormat.valueOf(rawFormat).name();
}
catch (IllegalArgumentException ex)
{
throw new IllegalArgumentException(format("Format must be one of %s", VALID_FORMATS));
}
}
}
@Override
public synchronized boolean start(Map<String, String> parameters)
{
if (isRunning())
return false;
validateStartParameters(parameters);
try
{
run(new ThrowingFunction<>()
{
@Override
public Object apply(AsyncProfiler profiler) throws ThrowableView on GitHub (pinned to 88fd0f6a0e)
Solutions
- Check the exception/VALID_FORMATS list and pass an exact enum name (e.g. 'flamegraph', 'tree', 'collapsed')
- Match case exactly — the lookup uses AsyncProfilerFormat.valueOf, which is case-sensitive
- Upgrade/align Cassandra version if your tooling uses a format from a different version
- Catch IllegalArgumentException in your tooling and retry with a valid default format
Example fix
// before
params.put("format", "FlameGraph");
// after
params.put("format", "flamegraph"); Defensive patterns
Strategy: validation
Validate before calling
Set<String> valid = AsyncProfilerService.VALID_FORMATS; // or list AsyncProfilerFormat values
if (format == null || !valid.contains(format)) throw new IllegalArgumentException("format must be one of " + valid); Try / catch
try { svc.apply(params, file); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith("Format must be one of")) { params.put("format", "flamegraph"); svc.apply(params, file); } else throw e; } Prevention
- Use the AsyncProfilerFormat enum constants instead of hand-written strings
- Copy format names from the VALID_FORMATS list in the error message exactly
- Remember the lookup is case-sensitive
When it happens
Trigger: Calling MBean start()/cmd() (or testAdvancedModeEnabledSuccess-style apply flows) with parameters map containing format=<value> where <value> is not one of the AsyncProfilerFormat constant names (e.g. 'tree' vs 'flamegraph', typos, wrong case).
Common situations: Typo in the format name; copying an async-profiler CLI option name that differs from the enum name; case-sensitivity mistakes (valueOf is case-sensitive); documentation drift across Cassandra versions when new formats were added.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Keyspace not specified.
- Table not specified.
- Table id not specified.
- Event can not be null nor blank string.
- Event must be one or a combination of %s
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/084ffb3f5cf1a083.
Report an issue: GitHub.