{"record":{"id":"b9186304253f8c61","repo":"apache/cassandra","slug":"do-not-specify-additional-arguments-when-categor","errorCode":null,"errorMessage":"Do not specify additional arguments when --category/-c is set.","messagePattern":"Do not specify additional arguments when --category/-c is set\\.","errorType":"console","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/GuardrailsConfigCommand.java","lineNumber":74,"sourceCode":"    @Command(name = \"getguardrailsconfig\", description = \"Print runtime configuration of guardrails.\")\n    public static class GetGuardrailsConfig extends GuardrailsConfigCommand\n    {\n        @Option(names = { \"--category\", \"-c\" },\n                description = \"Category of guardrails to filter, can be one of 'values', 'thresholds', 'flags', 'others'.\")\n        private GuardrailCategory guardrailCategory;\n\n        @Option(names = { \"--expand\" },\n        description = \"Expand all guardrail names so they reflect their counterparts in cassandra.yaml\")\n        private boolean expand = false;\n\n        @Parameters(index = \"0\", arity = \"0..1\", description = \"Specific name of a guardrail to get configuration of or all guardrails if not specified.\")\n        private String guardrailName;\n\n        @Override\n        public void execute(NodeProbe probe)\n        {\n            if (guardrailName != null && guardrailCategory != null)\n                throw new IllegalStateException(\"Do not specify additional arguments when --category/-c is set.\");\n\n            Map<String, List<Method>> allGetters = parseGuardrailNames(probe.getGuardrailsMBean().getClass().getDeclaredMethods(), guardrailName);\n\n            if (allGetters.isEmpty())\n            {\n                assert guardrailName != null;\n                throw new IllegalStateException(format(\"Guardrail %s not found.\", guardrailName));\n            }\n\n            display(probe, allGetters, guardrailCategory, expand);\n        }\n\n        @VisibleForTesting\n        public static Map<String, List<Method>> parseGuardrailNames(Method[] guardrailsMethods, String guardrailName)\n        {\n            Map<String, List<Method>> allGetters = stream(guardrailsMethods)\n                                                   .filter(method -> method.getName().startsWith(\"get\")\n                                                                     && !method.getName().endsWith(\"CSV\")","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/GuardrailsConfigCommand.java#L56-L92","documentation":"nodetool guardrails-config set/display rejects combining the --category/-c option with an additional positional guardrail-name argument, throwing IllegalStateException. The two ways of scoping output are exclusive: either a category or a specific guardrail.","triggerScenarios":"Running e.g. `nodetool guardrailsconfig --category read myguardrail` — both a guardrail name argument and a category flag are supplied.","commonSituations":"Appending a guardrail name out of habit while a category flag is already present; scripting tools that add both filters unconditionally.","solutions":["Remove the positional guardrail name and use only --category/-c.","Remove --category/-c and query the single guardrail by name.","Run `nodetool help guardrails-config` to see accepted argument shapes."],"exampleFix":"// before\nnodetool guardrailsconfig get --category read consistency\n// after\nnodetool guardrailsconfig get --category read","handlingStrategy":"validation","validationCode":"def validate_guardrails_args(category, name):\n    if category and name:\n        raise SystemExit('Use either --category/-c or a guardrail name, not both.')","typeGuard":null,"tryCatchPattern":"try {\n    displayGuardrails(...);\n} catch (IllegalStateException e) {\n    System.err.println(e.getMessage() + \" — drop either --category or the positional name.\");\n}","preventionTips":["Choose one scoping mechanism per invocation.","Don't blanket-add both filters in wrapper scripts."],"tags":["cli","nodetool","guardrails","mutually-exclusive"],"backgroundTag":"mutually-exclusive-options","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"}