{"record":{"id":"6af1eb8897a7a0b2","repo":"redis/jedis","slug":"either-frommember-or-fromlonlat-must-be-used","errorCode":null,"errorMessage":"Either FROMMEMBER or FROMLONLAT must be used.","messagePattern":"Either FROMMEMBER or FROMLONLAT must be used\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/params/GeoSearchParam.java","lineNumber":125,"sourceCode":"\n  public GeoSearchParam any() {\n    if (this.count == null) {\n      throw new IllegalArgumentException(\"COUNT must be set before ANY to be set\");\n    }\n    this.any = true;\n    return this;\n  }\n\n  @Override\n  public void addParams(CommandArguments args) {\n    if (fromMember && fromLonLat) {\n      throw new IllegalArgumentException(\"Both FROMMEMBER and FROMLONLAT cannot be used.\");\n    } else if (fromMember) {\n      args.add(Keyword.FROMMEMBER).add(member);\n    } else if (fromLonLat) {\n      args.add(Keyword.FROMLONLAT).add(coord.getLongitude()).add(coord.getLatitude());\n    } else {\n      throw new IllegalArgumentException(\"Either FROMMEMBER or FROMLONLAT must be used.\");\n    }\n\n    if (byRadius && byBox) {\n      throw new IllegalArgumentException(\"Both BYRADIUS and BYBOX cannot be used.\");\n    } else if (byRadius) {\n      args.add(Keyword.BYRADIUS).add(radius).add(unit);\n    } else if (byBox) {\n      args.add(Keyword.BYBOX).add(width).add(height).add(unit);\n    } else {\n      throw new IllegalArgumentException(\"Either BYRADIUS or BYBOX must be used.\");\n    }\n\n    if (withCoord) {\n      args.add(Keyword.WITHCOORD);\n    }\n    if (withDist) {\n      args.add(Keyword.WITHDIST);\n    }","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/params/GeoSearchParam.java#L107-L143","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Add .fromMember(member) or .fromLonLat(longitude, latitude) to the GeoSearchParam","If migrating from georadius(), pass the same center coordinates via fromLonLat(...)","Validate that an origin variable is non-null before building the params"],"exampleFix":"// before\nGeoSearchParam p = new GeoSearchParam().byRadius(100, GeoUnit.KM);\n// after\nGeoSearchParam p = new GeoSearchParam().fromLonLat(15.087831, 37.502669).byRadius(100, GeoUnit.KM);","handlingStrategy":"validation","validationCode":"if (originMember == null && originCoords == null) throw new IllegalStateException(\"GEOSEARCH needs fromMember or fromLonLat\");","typeGuard":null,"tryCatchPattern":"try {\n  jedis.geosearch(key, params);\n} catch (IllegalArgumentException e) {\n  log.error(\"GEOSEARCH origin missing\", e);\n}","preventionTips":["Migrating from GEORADIUS: always convert positional coordinates into fromLonLat(...)","Ensure conditional origin-setting code has a fallback","Always pair an origin with a shape in one builder expression"],"tags":["jedis","geosearch","missing-required-argument","illegal-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}