{"record":{"id":"a46f1a5c4df4fcec","repo":"quarkusio/quarkus","slug":"cannot-use-min-and-max-together","errorCode":null,"errorMessage":"Cannot use MIN and MAX together","messagePattern":"Cannot use MIN and MAX together","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/sortedset/ZMpopArgs.java","lineNumber":50,"sourceCode":"        this.max = true;\n        return this;\n    }\n\n    /**\n     * The optional {@code COUNT} can be used to specify the number of elements to pop, and is set to 1 by default.\n     *\n     * @param count the count value\n     * @return the current {@code ZmpopArgs}\n     **/\n    public ZMpopArgs count(int count) {\n        this.count = count;\n        return this;\n    }\n\n    @Override\n    public List<Object> toArgs() {\n        if (min && max) {\n            throw new IllegalArgumentException(\"Cannot use MIN and MAX together\");\n        }\n\n        List<Object> args = new ArrayList<>();\n        if (min) {\n            args.add(\"MIN\");\n        }\n        if (max) {\n            args.add(\"MAX\");\n        }\n\n        if (count > 0) {\n            args.add(\"COUNT\");\n            args.add(Integer.toString(count));\n        }\n\n        return args;\n    }\n}","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/sortedset/ZMpopArgs.java#L32-L68","documentation":"ZMPOPFROM... wait — ZMpopArgs models the MIN/MAX modifier of the ZMPOP command: pop the element with the lowest or highest score. Redis allows only one direction per call, so the library throws IllegalArgumentException in toArgs() if both flags are set.","triggerScenarios":"Chaining .min().max() on ZMpopArgs (or setting both booleans via separate code paths) before executing the zmpop command.","commonSituations":"Direction chosen dynamically (e.g. from config or a 'descending' flag) but both setters invoked; builder reuse across calls with different directions.","solutions":["Call only .min() or only .max() on a given ZMpopArgs","Create a new ZMpopArgs per invocation instead of mutating a shared instance","Ensure the direction code path is if/else, not two independent ifs"],"exampleFix":"// before\nZMpopArgs args = new ZMpopArgs().min().max();\n// after\nZMpopArgs args = new ZMpopArgs().min(); // or .max()","handlingStrategy":"validation","validationCode":"if (wantMin == wantMax) throw new IllegalArgumentException(\"ZMPOP direction must be exactly one of MIN/MAX\");","typeGuard":null,"tryCatchPattern":"try {\n    sortedSet.zmpop(keys, args);\n} catch (IllegalArgumentException e) {\n    // rebuild ZMpopArgs with one direction\n}","preventionTips":["Use if/else on a single direction boolean instead of two setters","Create a new ZMpopArgs per call","Default the direction explicitly (e.g. MIN) when input is ambiguous"],"tags":["redis","sorted-set","mutually-exclusive-options","zmpop"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}