{"record":{"id":"149f7eb79f9dd417","repo":"quarkusio/quarkus","slug":"byradius-and-bybox-cannot-be-used-together","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/GeoSearchArgs.java","lineNumber":194,"sourceCode":"     * <p>\n     * Using {@code ANY} requires {@code count} to be set.\n     *\n     * @return the current {@code GeoRadiusArgs}\n     **/\n    public GeoSearchArgs<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":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchArgs.java#L176-L212","documentation":"A GEOSEARCH query needs exactly one origin selector: either BYRADIUS or BYBOX for the area, and here specifically FROMMEMBER or FROMLONLAT for the center. toArgs detects that both a member and longitude/latitude were set and throws IllegalArgumentException, because the resulting command would be ambiguous and rejected by Redis.","triggerScenarios":"Calling both fromMember(m) and fromLongitudeLatitude(lon, lat) (or setting the coordinate fields directly) on the same GeoSearchArgs instance, then serializing via toArgs.","commonSituations":"Merging two args objects; builder code with conditional origin selection where both branches execute due to logic error; reusing an args instance and changing origin type without resetting the previous one.","solutions":["Set only one origin: remove the fromMember call if using coordinates, or vice versa","Choose the origin type before building and branch so only one setter runs","Create a fresh GeoSearchArgs instance instead of mutating a shared one"],"exampleFix":"// before\nGeoSearchArgs<String> args = GeoSearchArgs.fromMember(\"palermo\");\nargs.fromLongitudeLatitude(13.36, 38.11); // throws at toArgs\n// after\nGeoSearchArgs<String> args = GeoSearchArgs.fromLongitudeLatitude(13.36, 38.11);","handlingStrategy":"validation","validationCode":"boolean hasMemberOrigin = member != null; boolean hasCoordOrigin = lat != Double.MIN_VALUE; if (hasMemberOrigin && hasCoordOrigin) { throw new IllegalStateException(\"Choose FROMMEMBER or FROMLONLAT, not both\"); }","typeGuard":null,"tryCatchPattern":"try { geo.geoSearch(key, args); } catch (IllegalArgumentException e) { log.error(\"Conflicting geo origins: \" + e.getMessage()); }","preventionTips":["Pick one origin type per query and branch early","Create fresh GeoSearchArgs per request instead of mutating shared instances","When switching origin type, start from a new args object"],"tags":["redis","geo","illegal-argument","mutually-exclusive-options"],"backgroundTag":"invalid-argument-combination","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"}