{"record":{"id":"184365cf48271cc2","repo":"redis/jedis","slug":"both-frommember-and-fromlonlat-cannot-be-used","errorCode":null,"errorMessage":"Both FROMMEMBER and FROMLONLAT cannot be used.","messagePattern":"Both FROMMEMBER and FROMLONLAT cannot be used\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/params/GeoSearchParam.java","lineNumber":119,"sourceCode":"\n  public GeoSearchParam count(int count, boolean any) {\n    this.count = count;\n    this.any = true;\n    return this;\n  }\n\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","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/params/GeoSearchParam.java#L101-L137","documentation":"GEOSEARCH accepts exactly one origin: FROMMEMBER (a sorted-set member) or FROMLONLAT (coordinates). GeoSearchParam.addParams() detects that both fromMember and fromLonLat were set and refuses to build a command that Redis would reject, throwing this IllegalArgumentException client-side.","triggerScenarios":"Calling both .fromMember(...) and .fromLonLat(lon, lat) (or .fromCoordinate(...)) on the same GeoSearchParam before executing GEOSEARCH or GEOSEARCHSTORE.","commonSituations":"Merging two param-building code paths that each set a different origin; conditionally setting an origin but accidentally setting both branches; copy-paste leaving a stale fromLonLat default.","solutions":["Remove one of the two origin calls so only fromMember OR fromLonLat remains","If the origin is dynamic, branch explicitly and set only one, e.g. member != null ? param.fromMember(member) : param.fromLonLat(lon, lat)","Reset/rebuild the GeoSearchParam instead of reusing one that already has an origin set"],"exampleFix":"// before\nGeoSearchParam p = new GeoSearchParam().fromMember(\"palermo\").fromLonLat(15.0, 37.0);\n// after\nGeoSearchParam p = new GeoSearchParam().fromMember(\"palermo\");","handlingStrategy":"type-guard","validationCode":"if (fromMember != null && coords != null) throw new IllegalStateException(\"Set only one GEOSEARCH origin: FROMMEMBER or FROMLONLAT\");","typeGuard":"GeoSearchParam origin(GeoSearchParam p, String member, double lon, double lat) {\n  return member != null ? p.fromMember(member) : p.fromLonLat(lon, lat);\n}","tryCatchPattern":"try {\n  jedis.geosearch(key, params);\n} catch (IllegalArgumentException e) {\n  params = rebuildWithSingleOrigin();\n}","preventionTips":["Use a single helper that picks exactly one origin","Rebuild params when switching origins instead of mutating a shared instance","Don't set default origins that may collide with later calls"],"tags":["jedis","geosearch","mutually-exclusive","illegal-argument"],"backgroundTag":"mutually-exclusive-options","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"}