{"record":{"id":"97d545ed25d4b133","repo":"alibaba/nacos","slug":"plugin-config-value-is-not-a-boolean-key","errorCode":null,"errorMessage":"Plugin config value is not a boolean:  + key","messagePattern":"Plugin config value is not a boolean:  \\+ key","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/configuration/NacosAuthPluginConfig.java","lineNumber":136,"sourceCode":"        return result;\n    }\n    \n    private static long parsePositiveLong(String value, String key) {\n        try {\n            long result = Long.parseLong(value);\n            if (result <= 0) {\n                throw new IllegalArgumentException(\"Plugin config value must be positive: \" + key);\n            }\n            return result;\n        } catch (NumberFormatException e) {\n            throw new IllegalArgumentException(\"Plugin config value is not a number: \" + key, e);\n        }\n    }\n    \n    private static boolean parseBoolean(String value, String key) {\n        if (!Boolean.TRUE.toString().equalsIgnoreCase(value)\n            && !Boolean.FALSE.toString().equalsIgnoreCase(value)) {\n            throw new IllegalArgumentException(\"Plugin config value is not a boolean: \" + key);\n        }\n        return Boolean.parseBoolean(value);\n    }\n    \n    private static void validateTokenSecret(String tokenSecretKey) {\n        if (StringUtils.isBlank(tokenSecretKey)) {\n            return;\n        }\n        try {\n            new NacosJwtParser(tokenSecretKey);\n        } catch (RuntimeException e) {\n            throw new IllegalArgumentException(INVALID_SECRET_MESSAGE, e);\n        }\n    }\n    \n    public String getTokenSecretKey() {\n        return tokenSecretKey;\n    }","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/configuration/NacosAuthPluginConfig.java#L118-L154","documentation":"Thrown by parseBoolean() in NacosAuthPluginConfig when a boolean config value (token.cache.enable, caching.enabled, or anonymous.ai.enabled) is neither 'true' nor 'false' (case-insensitive). Any other token (e.g., '1', 'yes', 'on') is rejected.","triggerScenarios":"Setting token.cache.enable=yes or anonymous.ai.enabled=1; parseBoolean() compares against Boolean.TRUE/FALSE.toString() case-insensitively and neither matches, so the IllegalArgumentException fires.","commonSituations":"Using common-shell truthy values ('1', 'yes', 'on', 'enabled') instead of literal true/false; environment-variable overrides that pass non-canonical booleans.","solutions":["Use literal true or false for the boolean property.","Remove the property to accept the documented default (token.cache.enable=false, caching.enabled=true, anonymous.ai.enabled=false).","Normalize upstream boolean sources to 'true'/'false' strings before building the config map."],"exampleFix":"// before\nnacos.core.auth.plugin.nacos.token.cache.enable=yes\n\n// after\nnacos.core.auth.plugin.nacos.token.cache.enable=true","handlingStrategy":"validation","validationCode":"for (String boolKey : List.of(NacosAuthPluginConfig.TOKEN_CACHE_ENABLE,\n        NacosAuthPluginConfig.CACHING_ENABLED,\n        NacosAuthPluginConfig.ANONYMOUS_AI_ENABLED)) {\n    String v = config.get(boolKey);\n    if (v != null && !v.equalsIgnoreCase(\"true\") && !v.equalsIgnoreCase(\"false\")) {\n        throw new IllegalArgumentException(boolKey + \" must be true|false, got: \" + v);\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only literal true/false for boolean config keys.","Normalize environment-variable booleans to 'true'/'false' before building the map.","Reject '1'/'yes'/'on' at the config-source boundary."],"tags":["config","validation"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}