alibaba/nacos · error · IllegalArgumentException
Plugin config value must be positive: + key
Error message
Plugin config value must be positive: + key
What it means
Thrown by parsePositiveLong() in NacosAuthPluginConfig when a numeric config value (token.expire.seconds) parses successfully as a long but is less than or equal to zero. The method enforces strictly positive token lifetimes; zero or negative values are rejected with an IllegalArgumentException.
Source
Thrown at plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/configuration/NacosAuthPluginConfig.java:125
cachingEnabled, anonymousAiEnabled);
}
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 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;View on GitHub (pinned to 9b989acdf1)
Solutions
- Set token.expire.seconds to a positive integer (e.g., 18000 for ~5 hours, the typical default is 18000).
- Remove the property entirely to fall back to AuthConstants.DEFAULT_TOKEN_EXPIRE_SECONDS.
- Validate the value is > 0 in your config-management pipeline before deploy.
Example fix
// before nacos.core.auth.plugin.nacos.token.expire.seconds=0 // after nacos.core.auth.plugin.nacos.token.expire.seconds=18000
Defensive patterns
Strategy: validation
Validate before calling
String raw = config.get(NacosAuthPluginConfig.TOKEN_EXPIRE_SECONDS);
if (raw != null) {
long v = Long.parseLong(raw); // NumberFormatException -> 1263
if (v <= 0) throw new IllegalArgumentException("token.expire.seconds must be > 0, got " + v);
} Prevention
- Treat 0 as invalid — Nacos requires a strictly positive token lifetime.
- Validate config values in a preflight step before server boot.
- Use a config-management tool that enforces numeric ranges.
When it happens
Trigger: Configuring nacos.core.auth.plugin.nacos.token.expire.seconds=0 or a negative number; NacosAuthPluginConfig.from() calls parsePositiveLong() which Long.parseLong succeeds but the result <= 0 check fails.
Common situations: Setting token expiry to 0 intending 'no expiry' (Nacos does not support that); a negative value from a templated/misconfigured deployment; copy-paste of a duration with a stray minus sign.
Related errors
- Plugin config value is not a number: + key
- Base directory cannot be blank
- listener is null
- dataId={dataId}, group={group}
- 10000
AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14).
Data as JSON: /api/errors/981810a4c7ae4679.
Report an issue: GitHub.