alibaba/nacos · error · IllegalArgumentException

Plugin config value cannot be null:

Error message

Plugin config value cannot be null: 

What it means

Thrown by OidcAuthPluginConfig.value() when the config map explicitly contains a key but its value is null. This is distinct from a missing key (which falls back to the default). It signals a malformed config entry: the operator named the key but supplied null.

Source

Thrown at plugin-default-impl/nacos-oidc-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/oidc/config/OidcAuthPluginConfig.java:178

            AUTHORIZATION_TIMEOUT_MS);
        boolean strictNonceValidation = parseBoolean(value(config, STRICT_NONCE_VALIDATION,
            Boolean.toString(DEFAULT_STRICT_NONCE_VALIDATION)), STRICT_NONCE_VALIDATION);
        boolean strictAudienceValidation = parseBoolean(value(config,
            STRICT_AUDIENCE_VALIDATION, Boolean.toString(DEFAULT_STRICT_AUDIENCE_VALIDATION)),
            STRICT_AUDIENCE_VALIDATION);
        return new OidcAuthPluginConfig(issuerUri, clientId, clientSecret, scope,
            tokenValidationMethod, jwksCacheTtlSeconds, usernameClaim, rolesClaim, adminRole,
            autoCreateUser, authorizationEndpoint, authorizationTimeoutMs,
            strictNonceValidation, strictAudienceValidation);
    }
    
    private static String value(Map<String, String> config, String key, String defaultValue) {
        if (config == null || !config.containsKey(key)) {
            return defaultValue;
        }
        String result = config.get(key);
        if (result == null) {
            throw new IllegalArgumentException("Plugin config value cannot be null: " + key);
        }
        return StringUtils.isBlank(result) ? defaultValue : 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)

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Remove the offending key from the config so the default applies, or give it an explicit non-null string value.
  2. If building the map programmatically, filter out null values before passing to OidcAuthPluginConfig.from().
  3. The appended key name in the message identifies exactly which entry is null.

Example fix

// before: config map contains a null value
Map<String,String> cfg = new HashMap<>();
cfg.put("client-secret", null);
OidcAuthPluginConfig.from(cfg); // throws
// after: omit the key or supply a value
Map<String,String> cfg = new HashMap<>();
// client-secret omitted -> defaults to ""
OidcAuthPluginConfig.from(cfg);
Defensive patterns

Strategy: validation

Validate before calling

// Sanitize the config map before parsing: drop null-valued entries
Map<String, String> clean = new LinkedHashMap<>();
for (Map.Entry<String, String> e : rawConfig.entrySet()) {
    if (e.getValue() != null) {
        clean.put(e.getKey(), e.getValue());
    }
}
OidcAuthPluginConfig.from(clean);

Try / catch

try {
    OidcAuthPluginConfig.from(configMap);
} catch (IllegalArgumentException e) {
    if (e.getMessage().startsWith("Plugin config value cannot be null: ")) {
        String key = e.getMessage().substring("Plugin config value cannot be null: ".length());
        configMap.remove(key); // let the default apply
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: The plugin config map has an entry like {"client-secret": null} — the key is present with a null value. This typically happens when a config source maps an unset property to null rather than omitting it.

Common situations: A YAML/properties file with an empty value deserialized to null; a UI that writes the key with null when the field is cleared; programmatic config builders that put(key, null).

Related errors


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