quarkusio/quarkus · error · IllegalArgumentException

FROMMEMBER and FROMLONLAT cannot be used together

Error message

FROMMEMBER and FROMLONLAT cannot be used together

What it means

GeoSearchArgs.toArgs() validates that a GEOSEARCH origin is specified exactly once. If both a member (FROMMEMBER) and coordinates (FROMLONLAT) were set on the args builder, the library throws IllegalArgumentException because the Redis GEOSEARCH command accepts only one origin. It is a fail-fast misuse check, not a runtime failure.

Source

Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchArgs.java:198

     **/
    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");
            list.add(Double.toString(radius));
            list.add(unit.toString());
        } else {
            list.add("BYBOX");

View on GitHub (pinned to e1c734241f)

Solutions

  1. Use only one origin: call either fromMember(...) or fromLonLat(...), never both on the same args instance
  2. Create a fresh GeoSearchArgs instance per query instead of reusing builders
  3. Inspect the call path to find where the second origin-setting call happens and remove it

Example fix

// before
GeoSearchArgs<String> args = GeoSearchArgs.fromMember("palermo").fromLonLat(13.36, 38.11);
// after
GeoSearchArgs<String> args = GeoSearchArgs.fromLonLat(13.36, 38.11);
Defensive patterns

Strategy: validation

Validate before calling

if (argsHasMember && argsHasLonLat) {
    throw new IllegalStateException("Choose either fromMember or fromLonLat, not both");
}
geoSearch(key, args);

Try / catch

try {
    geoSearch(key, args);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("FROMMEMBER and FROMLONLAT")) {
        args = rebuildArgsWithSingleOrigin();
        geoSearch(key, args);
    } else throw e;
}

Prevention

When it happens

Trigger: Calling GeoSearchArgs methods that set both origin types on the same builder instance, e.g. chaining fromMember(m) and fromLonLat(lon, lat) (or reusing a builder that already had one origin set and adding the other) before executing a geosearch.

Common situations: Reusing a cached/shared GeoSearchArgs object across calls; building args conditionally where both branches run; copying settings from another args object without clearing the previous origin.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/b0a37a885a61aeb9. Report an issue: GitHub.