apache/cassandra · error · IllegalArgumentException

Event must be one or a combination of %s

Error message

Event must be one or a combination of %s

What it means

After null/blank validation, parseEvents attempts AsyncProfilerEvent.valueOf on each comma-separated token. Any token that is not a known event name produces an IllegalArgumentException, which is rethrown with a message listing all valid events, discarding the original detail.

Source

Thrown at src/java/org/apache/cassandra/service/AsyncProfilerService.java:184

            return name;
        }

        public static String parseEvents(String rawString)
        {
            if (rawString == null || rawString.isBlank())
                throw new IllegalArgumentException("Event can not be null nor blank string.");

            try
            {
                List<String> processedEvents = new ArrayList<>();
                for (String rawEvent : rawString.split(","))
                    processedEvents.add(AsyncProfilerEvent.valueOf(rawEvent).getEvent());

                return String.join(",", processedEvents);
            }
            catch (IllegalArgumentException ex)
            {
                throw new IllegalArgumentException(format("Event must be one or a combination of %s", VALID_EVENTS));
            }
        }
    }

    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)

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Use one of the valid event names exactly as listed in the error message (e.g. cpu, alloc, wall)
  2. Check the AsyncProfilerEvent enum for accepted names and spelling/case
  3. Join multiple events with commas: cpu,alloc

Example fix

// before
nodetool asyncprofiler heap
// after
nodetool asyncprofiler alloc
Defensive patterns

Strategy: validation

Validate before calling

Set<String> VALID = Set.of("cpu","alloc","wall","lock","cache","itimer");
for (String t : rawEvents.split(","))
    if (!VALID.contains(t)) throw new IllegalArgumentException("bad event: " + t);

Try / catch

try { startProfiling(events, format); }
catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Event must be one or a combination"))
        startProfiling("cpu", format); else throw e;
}

Prevention

When it happens

Trigger: Passing an unknown or misspelled event (e.g. 'cpo' instead of 'cpu', or 'memory' instead of 'alloc') to the async profiler events parameter, including case mismatches since valueOf is case-sensitive.

Common situations: Copying event names from async-profiler documentation (which uses different names than the AsyncProfilerEvent enum); forgetting that combinations are comma-separated and case-sensitive.

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


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/2ee6a0b3b6913f35. Report an issue: GitHub.