{"record":{"id":"084ffb3f5cf1a083","repo":"apache/cassandra","slug":"format-must-be-one-of-s","errorCode":null,"errorMessage":"Format must be one of %s","messagePattern":"Format must be one of (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/AsyncProfilerService.java","lineNumber":204,"sourceCode":"        }\n    }\n\n    public enum AsyncProfilerFormat\n    {\n        flat, traces, collapsed, flamegraph, tree, jfr;\n\n        public static String parseFormat(String rawFormat)\n        {\n            if (rawFormat == null || rawFormat.isBlank())\n                throw new IllegalArgumentException(\"Event can not be null nor blank string.\");\n\n            try\n            {\n                return AsyncProfilerFormat.valueOf(rawFormat).name();\n            }\n            catch (IllegalArgumentException ex)\n            {\n                throw new IllegalArgumentException(format(\"Format must be one of %s\", VALID_FORMATS));\n            }\n        }\n    }\n\n    @Override\n    public synchronized boolean start(Map<String, String> parameters)\n    {\n        if (isRunning())\n            return false;\n\n        validateStartParameters(parameters);\n\n        try\n        {\n            run(new ThrowingFunction<>()\n            {\n                @Override\n                public Object apply(AsyncProfiler profiler) throws Throwable","sourceCodeStart":186,"sourceCodeEnd":222,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/AsyncProfilerService.java#L186-L222","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before\nparams.put(\"format\", \"FlameGraph\");\n// after\nparams.put(\"format\", \"flamegraph\");","handlingStrategy":"validation","validationCode":"Set<String> valid = AsyncProfilerService.VALID_FORMATS; // or list AsyncProfilerFormat values\nif (format == null || !valid.contains(format)) throw new IllegalArgumentException(\"format must be one of \" + valid);","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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"],"tags":["validation","jmx","async-profiler"],"backgroundTag":"invalid-enum-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"}