quarkusio/quarkus · error · IllegalArgumentException
BYRADIUS and BYBOX cannot be used together
Error message
BYRADIUS and BYBOX cannot be used together
What it means
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.
Source
Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchArgs.java:194
* <p>
* Using {@code ANY} requires {@code count} to be set.
*
* @return the current {@code GeoRadiusArgs}
**/
public GeoSearchArgs<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
- 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
Example fix
// before
GeoSearchArgs<String> args = GeoSearchArgs.fromMember("palermo");
args.fromLongitudeLatitude(13.36, 38.11); // throws at toArgs
// after
GeoSearchArgs<String> args = GeoSearchArgs.fromLongitudeLatitude(13.36, 38.11); Defensive patterns
Strategy: validation
Validate before calling
boolean hasMemberOrigin = member != null; boolean hasCoordOrigin = lat != Double.MIN_VALUE; if (hasMemberOrigin && hasCoordOrigin) { throw new IllegalStateException("Choose FROMMEMBER or FROMLONLAT, not both"); } Try / catch
try { geo.geoSearch(key, args); } catch (IllegalArgumentException e) { log.error("Conflicting geo origins: " + e.getMessage()); } Prevention
- 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
When it happens
Trigger: Calling both fromMember(m) and fromLongitudeLatitude(lon, lat) (or setting the coordinate fields directly) on the same GeoSearchArgs instance, then serializing via toArgs.
Common situations: 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.
Related errors
- Cannot set XX and NX together
- ANY can only be used if COUNT is also set
- At least `STORE` or `STOREDIST` must be set
- `member` cannot be `null`
- `radius` must be positive
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/149f7eb79f9dd417.
Report an issue: GitHub.