quarkusio/quarkus · error · IllegalArgumentException

`width` must be positive

Error message

`width` must be positive

What it means

GeoSearchStoreArgs.byBox(width, height, unit) rejects a negative width with IllegalArgumentException. Redis BYBOX requires non-negative dimensions; a negative width is invalid input for the GEOSEARCHSTORE command.

Source

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

        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) {
        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}
     **/

View on GitHub (pinned to e1c734241f)

Solutions

  1. Compute the box as Math.abs(max - min) or normalize min/max before calling byBox
  2. Validate width >= 0 at the input boundary
  3. Fix the arithmetic producing the width

Example fix

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

Strategy: validation

Validate before calling

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

Type guard

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

Try / catch

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

Prevention

When it happens

Trigger: Calling byBox(-x, height, unit), typically from computed dimensions that went negative (e.g. subtracting coordinates or size arithmetic errors).

Common situations: Bounding-box computed from min/max points in the wrong order (max - min < 0); unsanitized user input; unit-conversion mistakes.

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/826a2fdf51ac142a. Report an issue: GitHub.