quarkusio/quarkus · error · IllegalArgumentException
`radius` must be positive
Error message
`radius` must be positive
What it means
GeoSearchStoreArgs.byRadius(radius, unit) rejects negative radius values with IllegalArgumentException ('positive' here means >= 0 in the implementation, since the check is radius < 0). Redis GEOSEARCHSTORE BYRADIUS requires a non-negative numeric radius; a negative value is invalid input.
Source
Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchStoreArgs.java:68
* @param latitude the latitude
* @return the current {@code GeoSearchStoreArgs}
*/
private GeoSearchStoreArgs<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 GeoSearchStoreArgs}
**/
public GeoSearchStoreArgs<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 GeoSearchStoreArgs}
**/
public GeoSearchStoreArgs<V> byBox(double width, double height, GeoUnit unit) {View on GitHub (pinned to e1c734241f)
Solutions
- Ensure the radius is >= 0 before calling byRadius (e.g. Math.max(0, radius))
- Validate user/config input at the boundary and reject negative radii with a friendly message
- Check the computation that produces the radius for sign errors
Example fix
// before double radius = maxKm - usedKm; // can be negative args.byRadius(radius, GeoUnit.km); // after double radius = Math.max(0, maxKm - usedKm); args.byRadius(radius, GeoUnit.km);
Defensive patterns
Strategy: validation
Validate before calling
if (radius < 0) {
throw new IllegalArgumentException("radius must be >= 0, got " + radius);
}
args.byRadius(radius, unit); Type guard
boolean isValidRadius(double radius) { return !Double.isNaN(radius) && radius >= 0; } Try / catch
try {
args.byRadius(radius, unit);
} catch (IllegalArgumentException e) {
log.error("Invalid radius {}: {}", radius, e.getMessage());
throw new BadRequestException("Radius must be non-negative");
} Prevention
- Clamp computed radii with Math.max(0, value)
- Validate user-supplied radii at the REST/config boundary
- Add tests for negative and NaN inputs
When it happens
Trigger: Calling byRadius with a negative double, e.g. byRadius(-5, GeoUnit.km), usually from a computed/unsanitized value (user input, subtraction that went negative, unparsed config).
Common situations: Search-radius computed as (a - b) that can go negative; user-supplied radius not validated; unit-conversion arithmetic errors.
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
- `width` must be positive
- `height` must be positive
- FROMMEMBER and FROMLONLAT cannot be used together
- `member` cannot be `null`
- `unit` cannot be `null`
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/32e4dac0ef5911df.
Report an issue: GitHub.