quarkusio/quarkus · error · IllegalArgumentException

`%s` must be greater than zero`

Error message

`%s` must be greater than zero`

What it means

Validation.positive(double, String) requires a strictly positive amount (> 0) for Redis commands whose arguments must be greater than zero (e.g. counts, radii, increments). Zero or negative amounts are rejected locally with IllegalArgumentException.

Source

Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/Validation.java:124

    static void validateLatitude(double latitude) {
        if (latitude < -85.05112878 || latitude > 85.05112878) {
            throw new IllegalArgumentException("The latitude must be in [85.05112878, 85.05112878]");
        }
    }

    public static void validateTimeout(Duration value, String name) {
        if (value == null) {
            throw new IllegalArgumentException(String.format("`%s` must not be `null`", name));
        }
        if (value.isNegative()) {
            throw new IllegalArgumentException(String.format("`%s` must be greater than or equal to zero", name));
        }
    }

    public static void positive(double amount, String name) {
        if (amount <= 0) {
            throw new IllegalArgumentException(String.format("`%s` must be greater than zero`", name));
        }
    }

    public static void positiveOrZero(double amount, String name) {
        if (amount < 0) {
            throw new IllegalArgumentException(String.format("`%s` must be greater or equal to zero", name));
        }
    }

    public static void isBit(int b, String name) {
        if (b != 0 && b != 1) {
            throw new IllegalArgumentException(String.format("`%s` must be either `0` or `1`", name));
        }
    }

}

View on GitHub (pinned to e1c734241f)

Solutions

  1. Ensure the amount is > 0 before the call, choosing a sensible minimum (e.g. Math.max(1, amount))
  2. Fix the upstream computation that yields 0 or negative values
  3. Give the configuration property a positive default
  4. Skip the command when the amount is not positive, if calling it is not meaningful

Example fix

// before
double radius = distanceTo(target); // may be 0.0
redis.geosearch(key, member, radius, SearchArgs km);
// after
double radius = distanceTo(target);
if (radius > 0) {
    redis.geosearch(key, member, radius, SearchArgs km);
}
Defensive patterns

Strategy: validation

Validate before calling

static boolean isPositive(double v) { return v > 0; }
if (!isPositive(amount)) throw new IllegalArgumentException("amount must be > 0, got " + amount);

Try / catch

try { redis.incrByFloat(key, amount); } catch (IllegalArgumentException e) { log.warn("Non-positive amount: {}", e.getMessage()); }

Prevention

When it happens

Trigger: Calling a Redis API that routes through Validation.positive (e.g. INCRBY-style amount, GEOSEARCH radius inputs, ZADD/limit parameters) with 0 or a negative double, often from a computed delta or an uninitialized 0.0 default.

Common situations: A computation returned 0 because inputs were equal or empty; a config property defaulting to 0; unit mistakes (meters vs kilometers) producing tiny/zero effective values; counter underflow producing negative amounts.

Related errors


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