{"record":{"id":"981810a4c7ae4679","repo":"alibaba/nacos","slug":"plugin-config-value-must-be-positive-key","errorCode":null,"errorMessage":"Plugin config value must be positive:  + key","messagePattern":"Plugin config value must be positive:  \\+ 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":125,"sourceCode":"            cachingEnabled, anonymousAiEnabled);\n    }\n    \n    private static String value(Map<String, String> config, String key, String defaultValue) {\n        if (config == null || !config.containsKey(key)) {\n            return defaultValue;\n        }\n        String result = config.get(key);\n        if (result == null) {\n            throw new IllegalArgumentException(\"Plugin config value cannot be null: \" + key);\n        }\n        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;","sourceCodeStart":107,"sourceCodeEnd":143,"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#L107-L143","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nnacos.core.auth.plugin.nacos.token.expire.seconds=0\n\n// after\nnacos.core.auth.plugin.nacos.token.expire.seconds=18000","handlingStrategy":"validation","validationCode":"String raw = config.get(NacosAuthPluginConfig.TOKEN_EXPIRE_SECONDS);\nif (raw != null) {\n    long v = Long.parseLong(raw); // NumberFormatException -> 1263\n    if (v <= 0) throw new IllegalArgumentException(\"token.expire.seconds must be > 0, got \" + v);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["config","validation","token"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}