{"record":{"id":"466639e07dfae53a","repo":"redis/jedis","slug":"either-byradius-or-bybox-must-be-used","errorCode":null,"errorMessage":"Either BYRADIUS or BYBOX must be used.","messagePattern":"Either BYRADIUS or BYBOX must be used\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/params/GeoSearchParam.java","lineNumber":135,"sourceCode":"  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    }\n    if (withHash) {\n      args.add(Keyword.WITHHASH);\n    }\n\n    if (count != null) {\n      args.add(Keyword.COUNT).add(count);\n      if (any) {\n        args.add(Keyword.ANY);\n      }\n    }","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/params/GeoSearchParam.java#L117-L153","documentation":"GEOSEARCH requires a search area definition; without BYRADIUS or BYBOX the command is invalid. GeoSearchParam.addParams() verifies that exactly one shape was configured and throws this IllegalArgumentException when neither is set.","triggerScenarios":"Executing GEOSEARCH/GEOSEARCHSTORE with a GeoSearchParam that has only an origin and/or options (e.g. new GeoSearchParam().fromMember(\"sicily\").withCoord()) but no byRadius(...) or byBox(...) call.","commonSituations":"Forgetting the shape when constructing params incrementally; conditional shape code where the condition never fired; incomplete migration from GEORADIUS where the radius became a separate param call that was dropped.","solutions":["Add .byRadius(radius, unit) or .byBox(width, height, unit) to the GeoSearchParam","Validate the radius/box inputs before building params so the shape call is always reached","Rebuild the param chain ensuring origin + shape are both present"],"exampleFix":"// before\nGeoSearchParam p = new GeoSearchParam().fromMember(\"sicily\").withCoord();\n// after\nGeoSearchParam p = new GeoSearchParam().fromMember(\"sicily\").byRadius(100, GeoUnit.KM).withCoord();","handlingStrategy":"validation","validationCode":"if (radius == null && (boxW == null || boxH == null)) throw new IllegalStateException(\"GEOSEARCH needs byRadius or byBox\");","typeGuard":null,"tryCatchPattern":"try {\n  jedis.geosearch(key, params);\n} catch (IllegalArgumentException e) {\n  log.error(\"GEOSEARCH shape missing\", e);\n}","preventionTips":["Always include exactly one of byRadius/byBox when building GeoSearchParam","Ensure conditional shape code cannot be skipped entirely","Validate search inputs before constructing params"],"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"}