{"record":{"id":"5559c0cd05066715","repo":"apache/cassandra","slug":"use-true-or-false-values-for-booleans","errorCode":null,"errorMessage":"Use 'true' or 'false' values for booleans","messagePattern":"Use 'true' or 'false' values for booleans","errorType":"console","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/nodetool/GuardrailsConfigCommand.java","lineNumber":320,"sourceCode":"                arguments = thresholdArgs.toArray();\n            }\n\n            return arguments;\n        }\n\n        private Object castType(Class<?> targetType, String value) throws IllegalArgumentException\n        {\n            if (targetType == String.class)\n                return value.equals(\"null\") ? \"\" : value;\n            else if (targetType == int.class || targetType == Integer.class)\n                return getNumber(value, Integer::parseInt, -1);\n            else if (targetType == long.class || targetType == Long.class)\n                return getNumber(value, Long::parseLong, -1);\n            else if (targetType == boolean.class || targetType == Boolean.class)\n            {\n                return getNumber(value, (v) -> {\n                    if (!v.equals(\"true\") && !v.equals(\"false\"))\n                        throw new IllegalStateException(\"Use 'true' or 'false' values for booleans\");\n\n                    return Boolean.parseBoolean(v);\n                }, false);\n            }\n            else if (targetType == Set.class)\n            {\n                if (value == null || value.equals(\"null\") || value.equals(\"[]\"))\n                    return new HashSet<>();\n                else\n                    return new LinkedHashSet<>(Arrays.asList(value.split(\",\")));\n            }\n            else\n            {\n                throw new IllegalArgumentException(format(\"unsupported type: %s\", targetType));\n            }\n        }\n\n        private <T> T getNumber(String value, Function<String, T> transformer, T defaultValue)","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/nodetool/GuardrailsConfigCommand.java#L302-L338","documentation":"When coercing a command-line argument to a boolean parameter, the guardrails-config set command accepts only the literal strings 'true' or 'false'; any other spelling throws IllegalStateException 'Use 'true' or 'false' values for booleans'.","triggerScenarios":"Running `nodetool guardrailsconfig set <boolean_guardrail> yes` (or 1, True, FALSE) — any value other than lowercase 'true'/'false' for a boolean-typed setter parameter.","commonSituations":"Using shell-style 'yes/no' or '1/0'; capitalizing 'True' as in Python; quoting issues in scripts altering the value.","solutions":["Use exactly lowercase `true` or `false` for boolean guardrail values.","Remove surrounding quotes/case transformations in scripts.","Check the setter's parameter type to know whether the value must be boolean."],"exampleFix":"// before\nnodetool guardrailsconfig set some_boolean_guardrail yes\n// after\nnodetool guardrailsconfig set some_boolean_guardrail true","handlingStrategy":"validation","validationCode":"def validate_bool(v):\n    if v not in ('true','false'):\n        raise SystemExit(\"booleans must be exactly 'true' or 'false'\")\n    return v","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use lowercase true/false only; never yes/no or 1/0.","Avoid case-transforming shells or templates changing the literal string."],"tags":["cli","nodetool","guardrails","boolean","invalid-value"],"backgroundTag":"invalid-argument-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}