{"record":{"id":"46c1eb07383db8a2","repo":"apache/cassandra","slug":"s-should-either-be-true-or-false-not-s-46c1eb","errorCode":null,"errorMessage":"%s should either be 'true' or 'false', not %s","messagePattern":"(.+?) should either be 'true' or 'false', not (.+?)","errorType":"validation","errorClass":"ConfigurationException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/compaction/unified/Controller.java","lineNumber":677,"sourceCode":"            }\n            catch (NumberFormatException e)\n            {\n                throw new ConfigurationException(String.format(\"%s is not a valid number between 0 and 1: %s\",\n                                                               SSTABLE_GROWTH_OPTION,\n                                                               e.getMessage()),\n                                                 e);\n            }\n        }\n\n        return options;\n    }\n\n    private static void validateBoolean(Map<String, String> options, String option)\n    {\n        String s;\n        s = options.remove(option);\n        if (s != null && !s.equalsIgnoreCase(\"true\") && !s.equalsIgnoreCase(\"false\")) {\n            throw new ConfigurationException(String.format(\"%s should either be 'true' or 'false', not %s\",\n                    option, s));\n        }\n    }\n\n    // The methods below are implemented here (rather than directly in UCS) to aid testability.\n\n    public double getBaseSstableSize(int F)\n    {\n        // The compaction hierarchy should start at a minimum size which is close to the typical flush size, with\n        // some leeway to make sure we don't overcompact when flushes end up a little smaller.\n        // The leeway should be less than 1/F, though, to make sure we don't overshoot the boundary combining F-1\n        // sources instead of F.\n        // Note that while we have not had flushes, the size will be 0 and we will use 1MB as the flush size. With\n        // fixed and positive W this should not hurt us, as the hierarchy will be in multiples of F and will still\n        // result in the same buckets, but for negative W or hybrid strategies this may cause temporary overcompaction.\n        // If this is a concern, the flush size override should be used to avoid it until DB-4401.\n        return Math.max(1 << 20, getFlushSizeBytes()) * (1.0 - 0.9 / F);\n    }","sourceCodeStart":659,"sourceCodeEnd":695,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/compaction/unified/Controller.java#L659-L695","documentation":"The controller's validateBoolean helper checks boolean compaction options (e.g. 'unsafe_aggressive_sstable_expiration'). The value must be the literal string 'true' or 'false' (case-insensitive). Any other string causes a ConfigurationException naming the option and offending value.","triggerScenarios":"Calling validateOptions (via table compaction options) with a boolean option set to values like 'yes', '1', 'on', or an empty string.","commonSituations":"Configs ported from systems that accept yes/1/on, shell scripts generating 'TRUE ' with stray whitespace, or hand-edited cassandra schema.","solutions":["Change the value to 'true' or 'false' exactly (case-insensitive, no surrounding whitespace).","Remove the option to use the default.","If generating config from scripts, coerce yes/1/on to true before writing the option."],"exampleFix":"// before\ncompaction = {'class': 'UnifiedCompactionStrategy', 'unsafe_aggressive_sstable_expiration': 'yes'};\n// after\ncompaction = {'class': 'UnifiedCompactionStrategy', 'unsafe_aggressive_sstable_expiration': 'true'};","handlingStrategy":"validation","validationCode":"for (String b : List.of(\"unsafe_aggressive_sstable_expiration\")) {\n    String v = options.get(b);\n    if (v != null && !v.equalsIgnoreCase(\"true\") && !v.equalsIgnoreCase(\"false\"))\n        throw new IllegalArgumentException(b + \" must be 'true' or 'false': \" + v);\n}","typeGuard":null,"tryCatchPattern":"try { strategy.validateOptions(opts); } catch (ConfigurationException e) { logger.error(\"Bad boolean option: {}\", e.getMessage()); }","preventionTips":["Normalize yes/1/on to true in config generators before writing options","Trim whitespace from generated option values","Document accepted literals in your config schema"],"tags":["cassandra","configuration","boolean"],"backgroundTag":"invalid-flag-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"}