{"record":{"id":"000d309292cd7f8d","repo":"alibaba/nacos","slug":"plugin-config-value-is-not-a-number-key","errorCode":null,"errorMessage":"Plugin config value is not a number:  + key","messagePattern":"Plugin config value is not a number:  \\+ 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":129,"sourceCode":"        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;\n        }\n        try {\n            new NacosJwtParser(tokenSecretKey);\n        } catch (RuntimeException e) {","sourceCodeStart":111,"sourceCodeEnd":147,"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#L111-L147","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nnacos.core.auth.plugin.nacos.token.expire.seconds=5h\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 && !raw.matches(\"\\\\d+\")) {\n    throw new IllegalArgumentException(\"token.expire.seconds must be a plain integer, got: \" + raw);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["config","validation","token"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}