quarkusio/quarkus · error · IllegalArgumentException
`width` must be positive
Error message
`width` must be positive
What it means
GeoSearchArgs.byBox defines a BYBOX search area with width, height, and unit; negative dimensions are geometrically invalid, so width is validated first and a negative value throws IllegalArgumentException. Height and unit get their own checks afterward, so this error indicates the width specifically was negative.
Source
Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchArgs.java:94
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) {
if (width < 0) {
throw new IllegalArgumentException("`width` must be positive");
}
if (height < 0) {
throw new IllegalArgumentException("`height` must be positive");
}
if (unit == null) {
throw new IllegalArgumentException("`unit` cannot be `null`");
}
this.width = width;
this.height = height;
this.unit = unit;
return this;
}
/**
* Use {@code ASC} order (from small to large).
*
* @return the current {@code GeoRadiusArgs}
**/View on GitHub (pinned to e1c734241f)
Solutions
- Ensure width is non-negative before calling byBox, e.g. Math.abs or taking max-min in the right order
- Fix the calculation that produces the box extent
- Validate config-provided dimensions at startup
Example fix
// before double width = x2 - x1; // x2 < x1 possible args.byBox(width, height, GeoUnit.KM); // after double width = Math.abs(x2 - x1); args.byBox(width, height, GeoUnit.KM);
Defensive patterns
Strategy: validation
Validate before calling
if (width < 0) { throw new IllegalStateException("width must be >= 0"); } Try / catch
try { args.byBox(width, height, unit); } catch (IllegalArgumentException e) { log.warn("Bad box: " + e.getMessage()); } Prevention
- Compute box extents as abs(max - min)
- Validate dimensions when loading from config
- Check argument order for width/height
When it happens
Trigger: Calling byBox(-5, 10, GeoUnit.KM) or passing a width derived from data that can go negative (difference of coordinates, sentinel value, bad parse).
Common situations: Bounding boxes computed from min/max points in wrong order producing negative extents; config sentinels of -1 meaning 'unset'; swapped width/height arguments.
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
- `radius` 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/e0f1eaa468b06ce8.
Report an issue: GitHub.