alibaba/nacos · error · IllegalArgumentException

Plugin config value is not a boolean: + key

Error message

Plugin config value is not a boolean:  + key

What it means

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.

Source

Thrown at plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/configuration/NacosAuthPluginConfig.java:136

        return result;
    }
    
    private static long parsePositiveLong(String value, String key) {
        try {
            long result = Long.parseLong(value);
            if (result <= 0) {
                throw new IllegalArgumentException("Plugin config value must be positive: " + key);
            }
            return result;
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("Plugin config value is not a number: " + key, e);
        }
    }
    
    private static boolean parseBoolean(String value, String key) {
        if (!Boolean.TRUE.toString().equalsIgnoreCase(value)
            && !Boolean.FALSE.toString().equalsIgnoreCase(value)) {
            throw new IllegalArgumentException("Plugin config value is not a boolean: " + key);
        }
        return Boolean.parseBoolean(value);
    }
    
    private static void validateTokenSecret(String tokenSecretKey) {
        if (StringUtils.isBlank(tokenSecretKey)) {
            return;
        }
        try {
            new NacosJwtParser(tokenSecretKey);
        } catch (RuntimeException e) {
            throw new IllegalArgumentException(INVALID_SECRET_MESSAGE, e);
        }
    }
    
    public String getTokenSecretKey() {
        return tokenSecretKey;
    }

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Use literal true or false for the boolean property.
  2. Remove the property to accept the documented default (token.cache.enable=false, caching.enabled=true, anonymous.ai.enabled=false).
  3. Normalize upstream boolean sources to 'true'/'false' strings before building the config map.

Example fix

// before
nacos.core.auth.plugin.nacos.token.cache.enable=yes

// after
nacos.core.auth.plugin.nacos.token.cache.enable=true
Defensive patterns

Strategy: validation

Validate before calling

for (String boolKey : List.of(NacosAuthPluginConfig.TOKEN_CACHE_ENABLE,
        NacosAuthPluginConfig.CACHING_ENABLED,
        NacosAuthPluginConfig.ANONYMOUS_AI_ENABLED)) {
    String v = config.get(boolKey);
    if (v != null && !v.equalsIgnoreCase("true") && !v.equalsIgnoreCase("false")) {
        throw new IllegalArgumentException(boolKey + " must be true|false, got: " + v);
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: Using common-shell truthy values ('1', 'yes', 'on', 'enabled') instead of literal true/false; environment-variable overrides that pass non-canonical booleans.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/97d545ed25d4b133. Report an issue: GitHub.