{"record":{"id":"5c172df06b5d031d","repo":"alibaba/nacos","slug":"invalid-boolean-value","errorCode":null,"errorMessage":"Invalid boolean value '{}'","messagePattern":"Invalid boolean value '(.+?)'","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"client-basic/src/main/java/com/alibaba/nacos/client/env/convert/BooleanConverter.java","lineNumber":53,"sourceCode":"        \n        FALSE_VALUES.add(\"false\");\n        FALSE_VALUES.add(\"off\");\n        FALSE_VALUES.add(\"no\");\n        FALSE_VALUES.add(\"0\");\n    }\n    \n    @Override\n    Boolean convert(String property) {\n        if (StringUtils.isEmpty(property)) {\n            return null;\n        }\n        property = property.toLowerCase();\n        if (TRUE_VALUES.contains(property)) {\n            return Boolean.TRUE;\n        } else if (FALSE_VALUES.contains(property)) {\n            return Boolean.FALSE;\n        } else {\n            throw new IllegalArgumentException(\"Invalid boolean value '\" + property + \"'\");\n        }\n    }\n}\n","sourceCodeStart":35,"sourceCodeEnd":57,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/client-basic/src/main/java/com/alibaba/nacos/client/env/convert/BooleanConverter.java#L35-L57","documentation":"Thrown by BooleanConverter.convert() as an IllegalArgumentException when the property string (case-insensitively) is not one of the accepted boolean values. Accepted TRUE values: 'true', 'on', 'yes', '1'. Accepted FALSE values: 'false', 'off', 'no', '0'. An empty or null string returns null (no error). Any other value throws. This converter is used by NacosClientProperties to coerce string-based configuration values to Boolean.","triggerScenarios":"A Nacos property expected to be boolean contains a value like 'Y', 'enable', 'disabled', '2', or any string not in the accepted set. The check is case-insensitive (toLowerCase is applied), so 'TRUE' works but 'Yeah' does not.","commonSituations":"Operators set a boolean property to 'enabled' or 'disabled' instead of 'true'/'false'; YAML 1.1 boolean parsing produces 'yes'/'no' which IS accepted but 'on'/'off' in unexpected contexts; numeric values other than 0/1.","solutions":["Check the property value from the exception message and change it to one of: true, false, on, off, yes, no, 1, 0.","If the value comes from an external system, normalize it to a recognized boolean string before injecting it into NacosClientProperties."],"exampleFix":"// before\nprops.setProperty(\"some.boolean.flag\", \"enabled\");\n\n// after\nprops.setProperty(\"some.boolean.flag\", \"true\");","handlingStrategy":"validation","validationCode":"Set<String> valid = Set.of(\"true\", \"false\", \"on\", \"off\", \"yes\", \"no\", \"1\", \"0\");\nString val = properties.getProperty(\"some.boolean.flag\");\nif (val != null && !valid.contains(val.toLowerCase())) {\n    throw new IllegalArgumentException(\"Boolean property must be one of \" + valid + \", got: \" + val);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Boolean value = nacosClientProperties.getProperty(\"flag\", Boolean.class);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Invalid boolean value\")) {\n        // Default to false or prompt for correction\n        properties.setProperty(\"flag\", \"false\");\n    } else {\n        throw e;\n    }\n}","preventionTips":["Document the accepted boolean values: true, false, on, off, yes, no, 1, 0.","Normalize external boolean inputs before injecting into Nacos properties.","Avoid using 'enabled'/'disabled' or 'Y'/'N' which are not accepted."],"tags":["configuration","type-conversion","validation","boolean"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}