quarkusio/quarkus · error · IllegalArgumentException
`radius` must be positive
Error message
`radius` must be positive
What it means
GeoSearchArgs.byRadius defines a BYRADIUS search area; a negative radius has no geometric meaning and Redis would reject or misinterpret it, so the client validates that radius >= 0 and throws IllegalArgumentException otherwise. The unit is validated separately. Note the check only rejects strictly negative values, so 0 is technically accepted.
Source
Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchArgs.java:74
* @param latitude the latitude
* @return the current {@code GeoSearchArgs}
*/
public GeoSearchArgs<V> fromCoordinate(double longitude, double latitude) {
this.longitude = longitude;
this.latitude = latitude;
return this;
}
/**
* Search inside circular area according to given {@code radius}.
*
* @param radius the radius value
* @param unit the unit
* @return the current {@code GeoSearchArgs}
**/
public GeoSearchArgs<V> byRadius(double radius, GeoUnit unit) {
if (radius < 0) {
throw new IllegalArgumentException("`radius` must be positive");
}
if (unit == null) {
throw new IllegalArgumentException("`unit` cannot be `null`");
}
this.radius = radius;
this.unit = unit;
return this;
}
/**
* Search inside circular area according to given {@code radius}.
*
* @param width the width of the box
* @param height the height of the box
* @param unit the unit
* @return the current {@code GeoSearchArgs}
**/
public GeoSearchArgs<V> byBox(double width, double height, GeoUnit unit) {View on GitHub (pinned to e1c734241f)
Solutions
- Pass a non-negative radius value; validate/normalize the input before calling byRadius
- Fix the upstream calculation or config default that yields a negative value
- Use Math.max(0, radius) only if a zero radius is an acceptable search result
Example fix
// before
double radius = max - min; // can be negative
args.byRadius(radius, GeoUnit.KM);
// after
double radius = Math.abs(max - min);
if (radius < 0) { throw new IllegalStateException("invalid radius"); }
args.byRadius(radius, GeoUnit.KM); Defensive patterns
Strategy: validation
Validate before calling
if (radius < 0) { throw new IllegalStateException("radius must be >= 0"); } Try / catch
try { args.byRadius(radius, unit); } catch (IllegalArgumentException e) { log.warn("Rejected radius: " + e.getMessage()); } Prevention
- Validate config-driven radii at startup
- Compute extents with abs/max-min to avoid negatives
- Avoid negative sentinels for 'unset' values
When it happens
Trigger: Calling byRadius(-1, GeoUnit.KM) or passing a radius computed from data that can be negative (e.g. a subtraction, a parsed config value with a sign, an unset default of -1).
Common situations: Config properties where a negative number is used as a 'disabled' sentinel; calculation errors producing negative distance; copy/paste of byBox width/height values into byRadius.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- ANY can only be used if COUNT is also set
- `width` must be positive
- `height` must be positive
- ANY can only be used if COUNT is also set
- At least `STORE` or `STOREDIST` must be set
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/6bc65c74005bb8aa.
Report an issue: GitHub.