quarkusio/quarkus · error · IllegalArgumentException

`height` must be positive

Error message

`height` must be positive

What it means

Thrown by GeoSearchStoreArgs.byBox when building a GEOSEARCH/GEORADIUSBYMEMBER-style bounding-box search with a negative height (width has its own sibling check). A box with a negative dimension describes no searchable area, so the argument guard rejects it immediately, naming 'height' as the offending dimension of the three (width, height, unit) parameters.

Source

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

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

View on GitHub (pinned to e1c734241f)

Solutions

  1. Compute height as Math.abs(maxLat - minLat) before calling byBox
  2. Validate height >= 0 at the input boundary
  3. Fix the ordering/arithmetic of the points used to derive the height

Example fix

// before
double height = p1.lat - p2.lat; // can be negative
args.byBox(width, height, GeoUnit.km);
// after
double height = Math.abs(p1.lat - p2.lat);
args.byBox(width, height, GeoUnit.km);
Defensive patterns

Strategy: validation

Validate before calling

if (height < 0) {
    throw new IllegalArgumentException("height must be >= 0, got " + height);
}
args.byBox(width, height, unit);

Type guard

boolean isValidHeight(double height) { return !Double.isNaN(height) && height >= 0; }

Try / catch

try {
    args.byBox(width, height, unit);
} catch (IllegalArgumentException e) {
    log.error("Invalid box height {}: {}", height, e.getMessage());
    throw new BadRequestException("Box dimensions must be non-negative");
}

Prevention

When it happens

Trigger: Calling byBox(width, -y, unit), usually from bounding-box arithmetic where the points are ordered so that max - min is negative, or from unsanitized input.

Common situations: Swapped min/max latitude when computing the box height; user-entered dimensions not validated; conversion errors between coordinate systems.

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/43208b815d735664. Report an issue: GitHub.