alibaba/nacos · error · IllegalArgumentException

Both parameters must be non-negative

Error message

Both parameters must be non-negative

What it means

Error "Both parameters must be non-negative" thrown in alibaba/nacos.

Source

Thrown at common/src/main/java/com/alibaba/nacos/common/utils/RandomUtils.java:82

        if (diff == 0) {
            return startInclusive;
        }
        return startInclusive + RANDOM.nextInt(diff);
    }
    
    /**
     * Check input parameters.
     *
     * @param startInclusive lower limit, must be non-negative
     * @param endExclusive   the upper bound (not included)
     */
    private static void checkParameters(final long startInclusive, final long endExclusive) {
        if (endExclusive < startInclusive) {
            throw new IllegalArgumentException(
                "startInclusive must be less than or equal to the endExclusive.");
        }
        if (startInclusive < 0) {
            throw new IllegalArgumentException("Both parameters must be non-negative");
        }
    }
}

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Correct the invalid value for RandomUtils negative parameter to match the expected format or allowed set, then retry.

When it happens

Trigger: Thrown at common/src/main/java/com/alibaba/nacos/common/utils/RandomUtils.java:82 when the library encounters an invalid state.

Common situations: Requesting a random value with a negative bound parameter.


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/92f6ab00307c2a05. Report an issue: GitHub.