{"record":{"id":"95b9918db7097fb3","repo":"quarkusio/quarkus","slug":"byradius-and-bybox-cannot-be-used-together-95b991","errorCode":null,"errorMessage":"BYRADIUS and BYBOX cannot be used together","messagePattern":"BYRADIUS and BYBOX cannot be used together","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchStoreArgs.java","lineNumber":156,"sourceCode":"     * <p>\n     * Using {@code ANY} requires {@code count} to be set.\n     *\n     * @return the current {@code GeoSearchStoreArgs}\n     **/\n    public GeoSearchStoreArgs<V> any() {\n        this.any = true;\n        return this;\n    }\n\n    @Override\n    public List<Object> toArgs(Codec codec) {\n        // Validation\n        if (any && count == -1) {\n            throw new IllegalArgumentException(\"ANY can only be used if COUNT is also set\");\n        }\n\n        if (radius > 0 && width > 0) {\n            throw new IllegalArgumentException(\"BYRADIUS and BYBOX cannot be used together\");\n        }\n\n        if (member != null && (latitude != Double.MIN_VALUE || longitude != Double.MIN_VALUE)) {\n            throw new IllegalArgumentException(\"FROMMEMBER and FROMLONLAT cannot be used together\");\n        }\n\n        List<Object> list = new ArrayList<>();\n        if (member != null) {\n            list.add(\"FROMMEMBER\");\n            list.add(new String(codec.encode(member), StandardCharsets.UTF_8));\n        } else {\n            list.add(\"FROMLONLAT\");\n            list.add(Double.toString(longitude));\n            list.add(Double.toString(latitude));\n        }\n\n        if (radius > 0) {\n            list.add(\"BYRADIUS\");","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchStoreArgs.java#L138-L174","documentation":"GeoSearchStoreArgs.toArgs() validates that only one distance shape is specified. GEOSEARCHSTORE accepts either BYRADIUS or BYBOX, not both; if both radius > 0 and width > 0 were set, the library throws IllegalArgumentException before sending the command.","triggerScenarios":"Calling both byRadius(...) and byBox(...) on the same GeoSearchStoreArgs instance, or reusing a builder that already had one shape set.","commonSituations":"Reusing args objects across requests; branching code that sets radius in one branch and box in another but both execute; copying settings from another args object.","solutions":["Use only one of byRadius or byBox per query","Create a fresh GeoSearchStoreArgs instance for each query","Remove the redundant shape-setting call found on the code path"],"exampleFix":"// before\nGeoSearchStoreArgs<String> args = GeoSearchStoreArgs.fromMember(\"m\").byRadius(10, GeoUnit.km).byBox(5, 5, GeoUnit.km);\n// after\nGeoSearchStoreArgs<String> args = GeoSearchStoreArgs.fromMember(\"m\").byRadius(10, GeoUnit.km);","handlingStrategy":"validation","validationCode":"if (useRadius && useBox) {\n    throw new IllegalStateException(\"Choose either byRadius or byBox, not both\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    geoSearchStore(key, dest, args);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"BYRADIUS and BYBOX\")) {\n        args = rebuildArgsWithSingleShape();\n        geoSearchStore(key, dest, args);\n    } else throw e;\n}","preventionTips":["One search shape per args instance; build fresh objects per query","Centralize shape selection in a single factory method","Test each shape mode in isolation"],"tags":["redis","argument-validation","geo-commands","mutually-exclusive"],"backgroundTag":"mutually-exclusive-arguments","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"}