quarkusio/quarkus · error · IllegalArgumentException
BYRADIUS and BYBOX cannot be used together
Error message
BYRADIUS and BYBOX cannot be used together
What it means
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.
Source
Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchStoreArgs.java:156
* <p>
* Using {@code ANY} requires {@code count} to be set.
*
* @return the current {@code GeoSearchStoreArgs}
**/
public GeoSearchStoreArgs<V> any() {
this.any = true;
return this;
}
@Override
public List<Object> toArgs(Codec codec) {
// Validation
if (any && count == -1) {
throw new IllegalArgumentException("ANY can only be used if COUNT is also set");
}
if (radius > 0 && width > 0) {
throw new IllegalArgumentException("BYRADIUS and BYBOX cannot be used together");
}
if (member != null && (latitude != Double.MIN_VALUE || longitude != Double.MIN_VALUE)) {
throw new IllegalArgumentException("FROMMEMBER and FROMLONLAT cannot be used together");
}
List<Object> list = new ArrayList<>();
if (member != null) {
list.add("FROMMEMBER");
list.add(new String(codec.encode(member), StandardCharsets.UTF_8));
} else {
list.add("FROMLONLAT");
list.add(Double.toString(longitude));
list.add(Double.toString(latitude));
}
if (radius > 0) {
list.add("BYRADIUS");View on GitHub (pinned to e1c734241f)
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
Example fix
// before
GeoSearchStoreArgs<String> args = GeoSearchStoreArgs.fromMember("m").byRadius(10, GeoUnit.km).byBox(5, 5, GeoUnit.km);
// after
GeoSearchStoreArgs<String> args = GeoSearchStoreArgs.fromMember("m").byRadius(10, GeoUnit.km); Defensive patterns
Strategy: validation
Validate before calling
if (useRadius && useBox) {
throw new IllegalStateException("Choose either byRadius or byBox, not both");
} Try / catch
try {
geoSearchStore(key, dest, args);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("BYRADIUS and BYBOX")) {
args = rebuildArgsWithSingleShape();
geoSearchStore(key, dest, args);
} else throw e;
} Prevention
- 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
When it happens
Trigger: Calling both byRadius(...) and byBox(...) on the same GeoSearchStoreArgs instance, or reusing a builder that already had one shape set.
Common situations: 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.
Related errors
- FROMMEMBER and FROMLONLAT cannot be used together
- FROMMEMBER and FROMLONLAT cannot be used together
- `member` cannot be `null`
- `radius` must be positive
- `unit` cannot be `null`
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/95b9918db7097fb3.
Report an issue: GitHub.