{"record":{"id":"446ec54b466e241c","repo":"alibaba/nacos","slug":"plugin-config-value-must-be-positive-key-446ec5","errorCode":null,"errorMessage":"Plugin config value must be positive: {key}","messagePattern":"Plugin config value must be positive: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"plugin-default-impl/nacos-ldap-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthPluginConfig.java","lineNumber":141,"sourceCode":"            caseSensitive, ignorePartialResultException);\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    public String getUrl() {\n        return url;\n    }","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/plugin-default-impl/nacos-ldap-auth-plugin/src/main/java/com/alibaba/nacos/plugin/auth/impl/ldap/LdapAuthPluginConfig.java#L123-L159","documentation":"Thrown by LdapAuthPluginConfig.parsePositiveLong() when the timeout config value parses as a valid long but is zero or negative. The LDAP timeout must be a positive duration (milliseconds), so non-positive values are rejected with IllegalArgumentException naming the 'timeout' key.","triggerScenarios":"LdapAuthPluginConfig.from() parses the timeout key; the value (e.g. \"0\", \"-1\") is a number but <= 0, triggering the positivity check at line 141.","commonSituations":"An operator sets nacos.plugin.auth.ldap.timeout=0 intending 'no timeout' (which is not how this plugin works); a negative value slips in from a misconfigured environment variable.","solutions":["Set the timeout to a positive millisecond value (default is 3000).","If unsure, remove the timeout key from config to fall back to the 3000ms default.","Review the LDAP config file for a negative or zero timeout entry."],"exampleFix":"# before\nnacos.plugin.auth.ldap.timeout=0\n\n# after\nnacos.plugin.auth.ldap.timeout=3000","handlingStrategy":"validation","validationCode":"String timeoutStr = config.getOrDefault(\"timeout\", \"3000\");\nlong timeout = Long.parseLong(timeoutStr);\nif (timeout <= 0) {\n    throw new IllegalArgumentException(\"timeout must be positive\");\n}","typeGuard":"static boolean isValidPositiveLong(String value) {\n    try {\n        return Long.parseLong(value) > 0;\n    } catch (NumberFormatException e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    LdapAuthPluginConfig parsed = LdapAuthPluginConfig.from(config);\n} catch (IllegalArgumentException e) {\n    // if message contains 'must be positive', fix the timeout value\n}","preventionTips":["Always use a positive integer (milliseconds) for the LDAP timeout.","Default to 3000ms if unsure; do not set 0.","Validate config values in a pre-deploy dry run."],"tags":["auth","ldap","config","validation","timeout","illegal-argument","java"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}