{"record":{"id":"f3ac2bedffd74bf3","repo":"quarkusio/quarkus","slug":"weights-cannot-be-null","errorCode":null,"errorMessage":"`weights` cannot be `null`","messagePattern":"`weights` cannot be `null`","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/sortedset/ZAggregateArgs.java","lineNumber":30,"sourceCode":"        MIN,\n        MAX\n    }\n\n    private final List<Double> weights = new ArrayList<>();\n\n    private Aggregate aggregate;\n\n    /**\n     * Using the WEIGHTS option, it is possible to specify a multiplication factor for each input sorted set.\n     * This means that the score of every element in every input sorted set is multiplied by this factor before being\n     * passed to the aggregation function. When WEIGHTS is not given, the multiplication factors default to 1.\n     *\n     * @param weights the weight values\n     * @return the current {@code ZAggregateArgs}\n     **/\n    public ZAggregateArgs weights(double... weights) {\n        if (weights == null) {\n            throw new IllegalArgumentException(\"`weights` cannot be `null`\");\n        }\n        for (double weight : weights) {\n            this.weights.add(weight);\n        }\n        return this;\n    }\n\n    /**\n     * With the AGGREGATE option, it is possible to specify how the results of the union are aggregated.\n     * This option defaults to SUM, where the score of an element is summed across the inputs where it exists.\n     * When this option is set to either MIN or MAX, the resulting set will contain the minimum or maximum score of\n     * an element across the inputs where it exists.\n     *\n     * @param aggregate the aggregate value\n     * @return the current {@code ZAggregateArgs}\n     **/\n    public ZAggregateArgs aggregate(Aggregate aggregate) {\n        this.aggregate = aggregate;","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/sortedset/ZAggregateArgs.java#L12-L48","documentation":"ZAggregateArgs.weights(double...) stores per-input weights for ZUNION/ZINTER/WDIFF style aggregate commands. A null varargs array is not meaningful (varargs calls normally pass zero or more values), so the library rejects null explicitly with IllegalArgumentException to surface the mistake at the call site.","triggerScenarios":"Passing an explicit null: args.weights((double[]) null), or passing a possibly-null double[] variable obtained from elsewhere.","commonSituations":"Null returned from a config lookup or another method and passed straight through; confusion between 'no weights' (don't call weights()) and 'null weights'.","solutions":["Omit the weights() call entirely when no weights are needed","Pass an empty array: args.weights(new double[0])","Null-check the source of the array before forwarding it"],"exampleFix":"// before\nargs.weights(pushedWeights); // pushedWeights may be null\n// after\nif (pushedWeights != null) {\n    args.weights(pushedWeights);\n}","handlingStrategy":"validation","validationCode":"if (weights != null) args.weights(weights); // or args.weights(new double[0])","typeGuard":"boolean hasWeights(double[] w) { return w != null && w.length > 0; }","tryCatchPattern":"try {\n    args.weights(weights);\n} catch (IllegalArgumentException e) {\n    // fall back to default (no AGGREGATE weights) args\n}","preventionTips":["Don't call weights() when no weighting is desired","Null-check any weights array coming from config or another API","Distinguish 'unset' (skip call) from 'empty' (call with empty array)"],"tags":["redis","sorted-set","null-check","zaggregate"],"backgroundTag":"null-argument","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"}