{"record":{"id":"98024d2ca2e0b357","repo":"apache/pulsar","slug":"earlytokenrefreshpercent-must-be-greater-than-0-g","errorCode":null,"errorMessage":"earlyTokenRefreshPercent must be greater than 0, got: ${value}","messagePattern":"earlyTokenRefreshPercent must be greater than 0, got: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/oauth2/AuthenticationOAuth2.java","lineNumber":231,"sourceCode":"     *\n     * <p>If the string contains a decimal point it is interpreted as a fractional value in [0, 1]\n     * and used directly (e.g. {@code \"0.8\"} → 0.8). Otherwise the string is treated as an integer\n     * percentage and divided by 100 (e.g. {@code \"80\"} → 0.8, {@code \"100\"} → 1.0).\n     *\n     * @param value the raw string from the configuration map\n     * @return the resolved fractional percent, must be &gt; 0\n     * @throws IllegalArgumentException if the value cannot be parsed or is ≤ 0\n     */\n    static double parseEarlyRefreshPercent(String value) {\n        try {\n            double percent;\n            if (value.contains(\".\")) {\n                percent = Double.parseDouble(value);\n            } else {\n                percent = Integer.parseInt(value) / 100.0;\n            }\n            if (percent <= 0) {\n                throw new IllegalArgumentException(\n                        CONFIG_PARAM_EARLY_TOKEN_REFRESH_PERCENT + \" must be greater than 0, got: \" + value);\n            }\n            return percent;\n        } catch (NumberFormatException e) {\n            throw new IllegalArgumentException(\n                    \"Malformed configuration parameter: \" + CONFIG_PARAM_EARLY_TOKEN_REFRESH_PERCENT, e);\n        }\n    }\n\n    @Override\n    @Deprecated\n    public void configure(Map<String, String> authParams) {\n        throw new NotImplementedException(\"Deprecated; use EncodedAuthenticationParameterSupport\");\n    }\n\n    @Override\n    public void start() throws PulsarClientException {\n        flow.initialize();","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/apache/pulsar/blob/820761864ed8e2a7d2e52dd9763ad2ae117c1395/pulsar-client/src/main/java/org/apache/pulsar/client/impl/auth/oauth2/AuthenticationOAuth2.java#L213-L249","documentation":"parseEarlyRefreshPercent() parses the earlyTokenRefreshPercent config parameter (fraction like 0.2 or integer percent like 20) and rejects values <= 0 with this IllegalArgumentException, which includes the offending value. Like other places, <= 0 is invalid: use a fraction in (0,1) to enable, or >= 1 to disable.","triggerScenarios":"Including \"earlyTokenRefreshPercent\":\"0\" (or a negative number) in the OAuth2 auth params JSON passed to configure(); the message interpolates the raw value, e.g. 'earlyTokenRefreshPercent must be greater than 0, got: 0'.","commonSituations":"Using 0 intending 'disabled' — the correct disable value is >= 1; parsing a decimal-comma locale value ('0,2') failing to parse; whitespace or unit suffixes ('20%') causing a NumberFormatException which surfaces as 'Malformed configuration parameter' instead.","solutions":["Set the parameter to a positive fraction like 0.2, or an integer percent like 20.","To disable early refresh, use a value >= 1 (e.g. 1 or 100) instead of 0.","Remove the parameter entirely to use the default behavior."],"exampleFix":"// before\n{\"type\":\"oauth2\",\"authMethod\":\"client_secret_post\", \"earlyTokenRefreshPercent\":\"0\", ...} // throws\n// after\n{\"type\":\"oauth2\",\"authMethod\":\"client_secret_post\", \"earlyTokenRefreshPercent\":\"0.2\", ...}","handlingStrategy":"validation","validationCode":"String v = params.optString(\"earlyTokenRefreshPercent\", null);\nif (v != null) {\n    double d = v.contains(\".\") ? Double.parseDouble(v) : Integer.parseInt(v) / 100.0;\n    if (!(d > 0)) {\n        throw new IllegalStateException(\"earlyTokenRefreshPercent must be > 0, got: \" + v);\n    }\n}\nauth.configure(paramsJson);","typeGuard":null,"tryCatchPattern":"try {\n    auth.configure(paramsJson);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"earlyTokenRefreshPercent\")) {\n        log.error(\"Bad earlyTokenRefreshPercent value: {}\", e.getMessage());\n        params.remove(\"earlyTokenRefreshPercent\"); // retry with default\n        auth.configure(params.toString());\n        return;\n    }\n    throw e;\n}","preventionTips":["Use a fraction in (0,1) to enable early refresh; >= 1 disables — never 0.","Strip whitespace and '%' suffixes from config values before writing the JSON.","Omit the key entirely when you want defaults."],"tags":["pulsar-client","oauth2","configuration","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"820761864ed8e2a7d2e52dd9763ad2ae117c1395","analyzedAt":"2026-09-06T00:14:20.138Z","contentChangedAt":"2026-09-06T00:14:20.138Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}