{"record":{"id":"639638d9cea15147","repo":"apache/cassandra","slug":"unable-to-make-boolean-from-s","errorCode":null,"errorMessage":"Unable to make boolean from '%s'","messagePattern":"Unable to make boolean from '(.+?)'","errorType":"validation","errorClass":"MarshalException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/marshal/BooleanType.java","lineNumber":93,"sourceCode":"    @Override\n    public <V> V fromComparableBytes(ValueAccessor<V> accessor, ByteSource.Peekable comparableBytes, ByteComparable.Version version)\n    {\n        if (comparableBytes == null)\n            return accessor.empty();\n        int b = comparableBytes.next();\n        return accessor.valueOf(b == 1);\n    }\n\n    public ByteBuffer fromString(String source) throws MarshalException\n    {\n\n        if (source.isEmpty()|| source.equalsIgnoreCase(Boolean.FALSE.toString()))\n            return decompose(false);\n\n        if (source.equalsIgnoreCase(Boolean.TRUE.toString()))\n            return decompose(true);\n\n        throw new MarshalException(String.format(\"Unable to make boolean from '%s'\", source));\n    }\n\n    @Override\n    public Term fromJSONObject(Object parsed) throws MarshalException\n    {\n        if (parsed instanceof String)\n            return new Constants.Value(fromString((String) parsed));\n        else if (!(parsed instanceof Boolean))\n            throw new MarshalException(String.format(\n                    \"Expected a boolean value, but got a %s: %s\", parsed.getClass().getSimpleName(), parsed));\n\n        return new Constants.Value(getSerializer().serialize((Boolean) parsed));\n    }\n\n    @Override\n    public String toJSONString(ByteBuffer buffer, ProtocolVersion protocolVersion)\n    {\n        return getSerializer().deserialize(buffer).toString();","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/marshal/BooleanType.java#L75-L111","documentation":"BooleanType.fromString throws this when the input string is neither 'true' nor 'false' (case-insensitive). Cassandra's boolean parser accepts only these two literals; anything else (including '1', 'yes', or values with stray whitespace) is rejected. The failing string is included in the message.","triggerScenarios":"INSERT with '1'/'yes'/'on' or whitespace-padded variants into a boolean column via the fromString path; fromJSONObject with a string that is not true/false; localized boolean representations (e.g. 'vrai').","commonSituations":"Data imported from CSVs using 0/1 or yes/no conventions; config-driven inserts where booleans render with trailing whitespace; shell env vars carrying '1' for boolean flags.","solutions":["Use the exact literals true or false (any case, no extra whitespace)","Convert 0/1 or yes/no to true/false in the import/ETL layer","If column holds numeric flags, change type to tinyint and store 0/1","Trim and normalize the value before binding: value.trim().toLowerCase()"],"exampleFix":"// before\nINSERT INTO t (k, flag) VALUES (1, 'yes');\n// after\nINSERT INTO t (k, flag) VALUES (1, true);","handlingStrategy":"validation","validationCode":"public static void assertBooleanLiteral(String s) {\n    String t = s == null ? null : s.trim().toLowerCase();\n    if (!\"true\".equals(t) && !\"false\".equals(t))\n        throw new IllegalArgumentException(\"Not a boolean literal: \" + s);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Normalize 0/1, yes/no to true/false at the ETL boundary","Trim inputs before binding","Use typed driver setters (setBool) instead of string literals","Document allowed literals for import pipelines"],"tags":["cassandra","marshal","boolean","parsing"],"backgroundTag":"invalid-argument-format","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"}