{"record":{"id":"f084764a27006591","repo":"quarkusio/quarkus","slug":"s-must-be-greater-than-or-equal-to-zero","errorCode":null,"errorMessage":"`%s` must be greater than or equal to zero","messagePattern":"`(.+?)` must be greater than 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":118,"sourceCode":"\n    static void validateLongitude(double longitude) {\n        if (longitude < -180 || longitude > 180) {\n            throw new IllegalArgumentException(\"The longitude must be in [-180, 180]\");\n        }\n    }\n\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));","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/Validation.java#L100-L136","documentation":"The second branch of Validation.validateTimeout rejects negative Duration values for Redis command timeouts/TTLs. Redis time arguments must be non-negative, so the Quarkus Redis datasource throws IllegalArgumentException before issuing the command.","triggerScenarios":"Passing a negative Duration produced by subtracting a later timestamp from an earlier one (Duration.between with reversed order) or a misconfigured property like quarkus.redis.timeout=-1s, into a Redis command timeout parameter.","commonSituations":"Duration.between(creationTime, now) accidentally reversed; clock skew when computing expiry deltas; YAML/properties files containing negative values copied from tuning notes; math like now - expiry instead of expiry - now.","solutions":["Reorder Duration.between arguments so it is (start, end) not (end, start)","Clamp with a negative check: Duration negative-safe value = value.isNegative() ? Duration.ZERO : value","Fix the negative value in the configuration file","If the intent is 'no expiry', skip the timeout parameter entirely instead of passing a negative duration"],"exampleFix":"// before\nDuration age = Duration.between(now, createdAt); // negative\nredis.setTimeout(age);\n// after\nDuration age = Duration.between(createdAt, now);\nredis.setTimeout(age.isNegative() ? Duration.ZERO : age);","handlingStrategy":"validation","validationCode":"if (duration != null && duration.isNegative()) throw new IllegalArgumentException(\"negative duration: \" + duration);\nDuration safe = duration.isNegative() ? Duration.ZERO : duration;","typeGuard":null,"tryCatchPattern":"try { redis.setTimeout(d); } catch (IllegalArgumentException e) { log.warn(\"Negative timeout rejected: {}\", e.getMessage()); }","preventionTips":["Check Duration.between argument order (start, end)","Clamp negative computed durations to ZERO","Lint configuration files for negative duration values","Add assertions on computed durations in dev profile"],"tags":["redis","validation","duration","illegal-argument"],"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"}