{"record":{"id":"ee0ac81412660ea0","repo":"quarkusio/quarkus","slug":"s-must-be-greater-than-zero","errorCode":null,"errorMessage":"`%s` must be greater than zero`","messagePattern":"`(.+?)` must be greater than zero`","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/Validation.java","lineNumber":124,"sourceCode":"\n    static void validateLatitude(double latitude) {\n        if (latitude < -85.05112878 || latitude > 85.05112878) {\n            throw new IllegalArgumentException(\"The latitude must be in [85.05112878, 85.05112878]\");\n        }\n    }\n\n    public static void validateTimeout(Duration value, String name) {\n        if (value == null) {\n            throw new IllegalArgumentException(String.format(\"`%s` must not be `null`\", name));\n        }\n        if (value.isNegative()) {\n            throw new IllegalArgumentException(String.format(\"`%s` must be greater than or equal to zero\", name));\n        }\n    }\n\n    public static void positive(double amount, String name) {\n        if (amount <= 0) {\n            throw new IllegalArgumentException(String.format(\"`%s` must be greater than zero`\", name));\n        }\n    }\n\n    public static void positiveOrZero(double amount, String name) {\n        if (amount < 0) {\n            throw new IllegalArgumentException(String.format(\"`%s` must be greater or equal to zero\", name));\n        }\n    }\n\n    public static void isBit(int b, String name) {\n        if (b != 0 && b != 1) {\n            throw new IllegalArgumentException(String.format(\"`%s` must be either `0` or `1`\", name));\n        }\n    }\n\n}\n","sourceCodeStart":106,"sourceCodeEnd":141,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/Validation.java#L106-L141","documentation":"Validation.positive(double, String) requires a strictly positive amount (> 0) for Redis commands whose arguments must be greater than zero (e.g. counts, radii, increments). Zero or negative amounts are rejected locally with IllegalArgumentException.","triggerScenarios":"Calling a Redis API that routes through Validation.positive (e.g. INCRBY-style amount, GEOSEARCH radius inputs, ZADD/limit parameters) with 0 or a negative double, often from a computed delta or an uninitialized 0.0 default.","commonSituations":"A computation returned 0 because inputs were equal or empty; a config property defaulting to 0; unit mistakes (meters vs kilometers) producing tiny/zero effective values; counter underflow producing negative amounts.","solutions":["Ensure the amount is > 0 before the call, choosing a sensible minimum (e.g. Math.max(1, amount))","Fix the upstream computation that yields 0 or negative values","Give the configuration property a positive default","Skip the command when the amount is not positive, if calling it is not meaningful"],"exampleFix":"// before\ndouble radius = distanceTo(target); // may be 0.0\nredis.geosearch(key, member, radius, SearchArgs km);\n// after\ndouble radius = distanceTo(target);\nif (radius > 0) {\n    redis.geosearch(key, member, radius, SearchArgs km);\n}","handlingStrategy":"validation","validationCode":"static boolean isPositive(double v) { return v > 0; }\nif (!isPositive(amount)) throw new IllegalArgumentException(\"amount must be > 0, got \" + amount);","typeGuard":null,"tryCatchPattern":"try { redis.incrByFloat(key, amount); } catch (IllegalArgumentException e) { log.warn(\"Non-positive amount: {}\", e.getMessage()); }","preventionTips":["Guard computations that can yield 0 before issuing commands","Use Math.max(minimum, amount) as a floor","Validate config defaults are positive","Watch for unit conversions that zero out values"],"tags":["redis","validation","illegal-argument","numeric"],"backgroundTag":"invalid-argument-range","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}