{"record":{"id":"dbb4238ae953ec8a","repo":"quarkusio/quarkus","slug":"count-must-be-strictly-positive","errorCode":null,"errorMessage":"`count` must be strictly positive","messagePattern":"`count` must be strictly positive","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/ScanArgs.java","lineNumber":22,"sourceCode":"import java.util.List;\n\n/**\n * Represents the {@code scan} commands flags.\n */\npublic class ScanArgs {\n    private long count = -1;\n    private String match;\n\n    /**\n     * Sets the max number of items in each batch.\n     * The default value is 10.\n     *\n     * @param count the number of item, must be strictly positive\n     * @return the current {@code ScanArgs}\n     */\n    public ScanArgs count(long count) {\n        if (count <= 0) {\n            throw new IllegalArgumentException(\"`count` must be strictly positive\");\n        }\n        this.count = count;\n        return this;\n    }\n\n    /**\n     * Sets a {@code MATCH} pattern\n     *\n     * @param pattern the pattern, must not be {@code null}\n     * @return the current {@code ScanArgs}\n     */\n    public ScanArgs match(String pattern) {\n        if (pattern == null) {\n            throw new IllegalArgumentException(\"`pattern` must not be `null`\");\n        }\n        this.match = pattern;\n        return this;\n    }","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/ScanArgs.java#L4-L40","documentation":"ScanArgs.count(long) sets the COUNT option of Redis SCAN/SSCAN/etc. The Redis protocol requires COUNT to be a positive number, so the builder validates the argument and throws IllegalArgumentException when count <= 0.","triggerScenarios":"Calling scanArgs.count(0) or scanArgs.count(negative value) before passing ScanArgs to a keys()/scan-style datasource method.","commonSituations":"Computing a batch size from configuration or a division that yields 0 (e.g. totalItems/pageSize with rounding); uninitialized config defaults of 0; off-by-one or sign bugs.","solutions":["Pass a strictly positive value, e.g. scanArgs.count(100), or fix the computation producing 0/negative","Guard with Math.max(1, configuredCount) before building ScanArgs","Fix the configuration source so the batch-size property has a sane default (e.g. 10) instead of 0","Validate config at startup (config mapping constraints) to fail early on non-positive values"],"exampleFix":"// before\nlong batchSize = total / pages; // can be 0\nScanArgs args = new ScanArgs().count(batchSize);\n// after\nlong batchSize = Math.max(1, total / pages);\nScanArgs args = new ScanArgs().count(batchSize);","handlingStrategy":"validation","validationCode":"if (count <= 0) throw new IllegalArgumentException(\"count must be > 0, got \" + count);\nScanArgs args = new ScanArgs().count(count);","typeGuard":null,"tryCatchPattern":"try {\n    args = new ScanArgs().count(configuredCount);\n} catch (IllegalArgumentException e) {\n    args = new ScanArgs().count(10); // safe default\n}","preventionTips":["Clamp configured batch sizes with Math.max(1, value)","Validate batch-size config at startup","Unit-test scan helpers with edge-case configs (0, negatives)"],"tags":["quarkus","redis","validation","scan","illegal-argument"],"backgroundTag":"argument-must-be-positive","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"}