{"record":{"id":"521e71f66da3ce9f","repo":"quarkusio/quarkus","slug":"the-expansion-factory-must-be-positive","errorCode":null,"errorMessage":"the expansion factory must be positive","messagePattern":"the expansion factory must be positive","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/bloom/BfInsertArgs.java","lineNumber":78,"sourceCode":"     */\n    public BfInsertArgs nonScaling() {\n        this.nonScaling = true;\n        return this;\n    }\n\n    /**\n     * Set the expansion factory.\n     * When capacity is reached, an additional sub-filter is created. The size of the new sub-filter is the size of\n     * the last sub-filter multiplied by expansion. If the number of elements to be stored in the filter is unknown,\n     * we recommend that you use an expansion of 2 or more to reduce the number of sub-filters. Otherwise, we recommend\n     * that you use an expansion of 1 to reduce memory consumption. The default expansion value is 2.\n     *\n     * @param expansion the expansion factor, must be positive\n     * @return the current {@link BfInsertArgs}\n     */\n    public BfInsertArgs expansion(int expansion) {\n        if (expansion <= 0) {\n            throw new IllegalArgumentException(\"the expansion factory must be positive\");\n        }\n        this.expansion = expansion;\n        return this;\n    }\n\n    @Override\n    public List<Object> toArgs() {\n        List<Object> list = new ArrayList<>();\n\n        if (capacity > 0) {\n            list.add(\"CAPACITY\");\n            list.add(Long.toString(capacity));\n        }\n\n        if (errorRate != -1.0) {\n            list.add(\"ERROR\");\n            list.add(new BigDecimal(errorRate).toPlainString()); // Prevent E notation\n        }","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/bloom/BfInsertArgs.java#L60-L96","documentation":"BfInsertArgs.expansion(int) sets the BF.INSERT EXPANSION option for RedisBloom filters. The expansion factor (how each new sub-filter scales) must be a positive integer, so the method throws this IllegalArgumentException for zero or negative values, matching RedisBloom's own semantics.","triggerScenarios":"Calling bfInsertArgs.expansion(0) or expansion(-1) — usually because the expansion value came from configuration, an environment variable, or arithmetic that yielded <= 0.","commonSituations":"Unset config defaulting to 0 and being passed through unchanged; a division or subtraction producing a non-positive factor; copying constants from another bloom config where the field means something else.","solutions":["Pass a positive integer, e.g. expansion(2) (the common doubling strategy).","Clamp or default the value before calling: value <= 0 ? 2 : value.","Fix the configuration source that supplies the expansion factor."],"exampleFix":"// before\nargs.expansion(config.expansion()); // 0 when unset -> throws\n// after\nargs.expansion(config.expansion() > 0 ? config.expansion() : 2);","handlingStrategy":"validation","validationCode":"int expansion = config.expansion();\nif (expansion <= 0) {\n    expansion = 2; // standard doubling\n}\nargs.expansion(expansion);","typeGuard":null,"tryCatchPattern":"try { args.expansion(expansion); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"expansion\")) { args.expansion(2); } else { throw e; } }","preventionTips":["Give config properties a positive default (e.g. 2) instead of 0.","Validate all bloom-filter numeric options at config-load time.","Document that EXPANSION must be >= 1 in the property description."],"tags":["redis","bloom-filter","argument-validation"],"backgroundTag":"invalid-argument-value","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"}