alibaba/nacos · error · IllegalArgumentException
Plugin config value is not a number: + key
Error message
Plugin config value is not a number: + key
What it means
Thrown by parsePositiveLong() in NacosAuthPluginConfig when the token.expire.seconds value cannot be parsed as a long (Long.parseLong throws NumberFormatException). The NumberFormatException is caught and rethrown as an IllegalArgumentException naming the offending key.
Source
Thrown at plugin-default-impl/nacos-default-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/configuration/NacosAuthPluginConfig.java:129
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;
}
try {
new NacosJwtParser(tokenSecretKey);
} catch (RuntimeException e) {View on GitHub (pinned to 9b989acdf1)
Solutions
- Set token.expire.seconds to a plain integer (seconds), e.g., 18000.
- Remove any unit suffixes, commas, or whitespace from the value.
- If unset, remove the key so the default applies.
Example fix
// before nacos.core.auth.plugin.nacos.token.expire.seconds=5h // 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 && !raw.matches("\\d+")) {
throw new IllegalArgumentException("token.expire.seconds must be a plain integer, got: " + raw);
} Prevention
- Use plain integer seconds — no units, commas, or whitespace.
- Add a regex/parse preflight for numeric config keys.
- Lint config files for non-numeric values in numeric fields.
When it happens
Trigger: nacos.core.auth.plugin.nacos.token.expire.seconds is set to a non-numeric string (e.g., '5h', 'abc', '18,000'); parsePositiveLong() hits the catch (NumberFormatException) branch.
Common situations: Using a human-readable duration string ('5h', '30m') where a raw integer is required; locale-specific number formatting with a comma; a typo or trailing whitespace/unit suffix.
Related errors
- Plugin config value must be positive: + 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/000d309292cd7f8d.
Report an issue: GitHub.