quarkusio/quarkus · error · IllegalArgumentException

`height` must be positive

Error message

`height` must be positive

What it means

In byBox, after width is validated, the height is checked: a negative height throws IllegalArgumentException with this message. Both box dimensions must be non-negative to form a valid BYBOX area for GEOSEARCH.

Source

Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchArgs.java:97

        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}
     **/
    public GeoSearchArgs<V> ascending() {
        this.direction = "ASC";
        return this;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Ensure height is non-negative, e.g. Math.abs(y2 - y1)
  2. Reorder min/max computation so extents are always positive
  3. Check argument order if width and height may be swapped

Example fix

// before
double height = y1 - y2; // negative when y2 > y1
args.byBox(width, height, GeoUnit.KM);
// after
double height = Math.abs(y1 - y2);
args.byBox(width, height, GeoUnit.KM);
Defensive patterns

Strategy: validation

Validate before calling

if (height < 0) { throw new IllegalStateException("height must be >= 0"); }

Try / catch

try { args.byBox(width, height, unit); } catch (IllegalArgumentException e) { log.warn("Bad box height: " + e.getMessage()); }

Prevention

When it happens

Trigger: Calling byBox(10, -3, GeoUnit.KM) or passing a height computed from data that can be negative, e.g. y2 - y1 with points in descending order.

Common situations: Bounding boxes computed from unordered corner points; sentinel negative values from config; swapped width/height arguments so the negative value lands in height.

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


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/0064b7581e2f7923. Report an issue: GitHub.