redis/jedis · error · IllegalArgumentException

Either FROMMEMBER or FROMLONLAT must be used.

Error message

Either FROMMEMBER or FROMLONLAT must be used.

What it means

GEOSEARCH requires a search origin; without FROMMEMBER or FROMLONLAT the command is invalid. GeoSearchParam.addParams() checks that exactly one origin was configured and throws this IllegalArgumentException when neither flag is set, failing fast instead of sending a malformed command.

Solutions

  1. Add .fromMember(member) or .fromLonLat(longitude, latitude) to the GeoSearchParam
  2. If migrating from georadius(), pass the same center coordinates via fromLonLat(...)
  3. Validate that an origin variable is non-null before building the params

Example fix

// before
GeoSearchParam p = new GeoSearchParam().byRadius(100, GeoUnit.KM);
// after
GeoSearchParam p = new GeoSearchParam().fromLonLat(15.087831, 37.502669).byRadius(100, GeoUnit.KM);
Defensive patterns

Strategy: validation

Validate before calling

if (originMember == null && originCoords == null) throw new IllegalStateException("GEOSEARCH needs fromMember or fromLonLat");

Try / catch

try {
  jedis.geosearch(key, params);
} catch (IllegalArgumentException e) {
  log.error("GEOSEARCH origin missing", e);
}

Prevention

When it happens

Trigger: Executing GEOSEARCH/GEOSEARCHSTORE with a GeoSearchParam that only has byRadius/byBox (e.g. new GeoSearchParam().byRadius(100, GeoUnit.KM)) with no fromMember(...) or fromLonLat(...) call.

Common situations: Forgetting the origin when converting from GEORADIUS (which takes coordinates as positional args) to GEOSEARCH; conditional origin code where both conditions were false; reusing a params object incorrectly.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of redis/jedis@6dac31d4c2 (2026-09-08). Data as JSON: /api/errors/6af1eb8897a7a0b2. Report an issue: GitHub.

Appendix: source

Thrown at src/main/java/redis/clients/jedis/params/GeoSearchParam.java:125

  public GeoSearchParam any() {
    if (this.count == null) {
      throw new IllegalArgumentException("COUNT must be set before ANY to be set");
    }
    this.any = true;
    return this;
  }

  @Override
  public void addParams(CommandArguments args) {
    if (fromMember && fromLonLat) {
      throw new IllegalArgumentException("Both FROMMEMBER and FROMLONLAT cannot be used.");
    } else if (fromMember) {
      args.add(Keyword.FROMMEMBER).add(member);
    } else if (fromLonLat) {
      args.add(Keyword.FROMLONLAT).add(coord.getLongitude()).add(coord.getLatitude());
    } else {
      throw new IllegalArgumentException("Either FROMMEMBER or FROMLONLAT must be used.");
    }

    if (byRadius && byBox) {
      throw new IllegalArgumentException("Both BYRADIUS and BYBOX cannot be used.");
    } else if (byRadius) {
      args.add(Keyword.BYRADIUS).add(radius).add(unit);
    } else if (byBox) {
      args.add(Keyword.BYBOX).add(width).add(height).add(unit);
    } else {
      throw new IllegalArgumentException("Either BYRADIUS or BYBOX must be used.");
    }

    if (withCoord) {
      args.add(Keyword.WITHCOORD);
    }
    if (withDist) {
      args.add(Keyword.WITHDIST);
    }

View on GitHub (pinned to 6dac31d4c2)