{"record":{"id":"404263b1e42e02cb","repo":"quarkusio/quarkus","slug":"s-must-be-greater-or-equal-to-zero","errorCode":null,"errorMessage":"`%s` must be greater or equal to zero","messagePattern":"`(.+?)` must be greater or equal to 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":130,"sourceCode":"\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":112,"sourceCodeEnd":141,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/Validation.java#L112-L141","documentation":"Validation.positiveOrZero(double, String) accepts 0 or positive amounts and rejects only negative values for Redis command arguments that permit zero (e.g. offsets, limits). A negative double triggers IllegalArgumentException before the command is sent.","triggerScenarios":"Passing a negative double to an API that uses positiveOrZero validation, typically a negative offset/limit computed by subtracting values, or a negative config value like page-size=-5.","commonSituations":"Pagination math where (page-1)*size went negative for page=0; a negative value parsed from properties/YAML; floating-point underflow near zero (e.g. -1e-9 from iterative algorithms).","solutions":["Clamp: double safe = Math.max(0, value) before the call","Fix the pagination/index computation producing negative values","Correct the negative value in the configuration source","Treat -1e-9-scale underflow by snapping near-zero values to 0 (if (Math.abs(v) < epsilon) v = 0)"],"exampleFix":"// before\nlong offset = (page - 1) * size; // page=0 -> -size\nredis.zrange(key, offset, offset + size - 1);\n// after\nlong offset = Math.max(0, (page - 1) * size);\nredis.zrange(key, offset, offset + size - 1);","handlingStrategy":"validation","validationCode":"if (value < 0) throw new IllegalArgumentException(\"must be >= 0, got \" + value);\ndouble safe = Math.max(0, value);","typeGuard":null,"tryCatchPattern":"try { redisCommand(offset); } catch (IllegalArgumentException e) { log.warn(\"Negative offset: {}\", e.getMessage()); }","preventionTips":["Check pagination math for page=0 edge cases","Clamp offsets/limits with Math.max(0, x)","Snap near-zero floating point noise to 0 with an epsilon","Validate config values are non-negative at startup"],"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-12T22:17:10.623Z"}