bazelbuild/bazel · error · OptionsParsingException

'" + input + "' should be <= " + maxValue

Error message

'" + input + "' should be <= " + maxValue

What it means

Thrown by Converters.RangeConverter.convert when the parsed integer exceeds the converter's configured maxValue. It is the upper-bound counterpart of the 'should be >=' error: RangeConverter enforces both ends of a hard range at option-parse time and never clamps silently.

Source

Thrown at src/main/java/com/google/devtools/common/options/Converters.java:474

  /** Checks whether an integer is in the given range. */
  public static class RangeConverter extends Converter.Contextless<Integer> {
    final int minValue;
    final int maxValue;

    public RangeConverter(int minValue, int maxValue) {
      this.minValue = minValue;
      this.maxValue = maxValue;
    }

    @Override
    public Integer convert(String input) throws OptionsParsingException {
      try {
        int value = Integer.parseInt(input);
        if (value < minValue) {
          throw new OptionsParsingException("'" + input + "' should be >= " + minValue);
        } else if (value < minValue || value > maxValue) {
          throw new OptionsParsingException("'" + input + "' should be <= " + maxValue);
        }
        return value;
      } catch (NumberFormatException e) {
        throw new OptionsParsingException("'" + input + "' is not an int", e);
      }
    }

    @Override
    public String getTypeDescription() {
      if (minValue == Integer.MIN_VALUE) {
        if (maxValue == Integer.MAX_VALUE) {
          return "an integer";
        } else {
          return "an integer, <= " + maxValue;
        }
      } else if (maxValue == Integer.MAX_VALUE) {
        return "an integer, >= " + minValue;
      } else {

View on GitHub (pinned to e6e199d060)

Solutions

  1. Pass a value <= the maximum quoted in the message.
  2. Check the flag's type description (e.g. "an integer, <= 2147483647") for the enforced cap.
  3. Clamp generated values in your scripts to the documented range.

Example fix

# before
bazel build --my_capped_flag=10000 //...
# after
bazel build --my_capped_flag=1000 //...   # max from the error message
Defensive patterns

Strategy: validation

Validate before calling

boolean isInRange(String s, int min, int max) {
  try { int v = Integer.parseInt(s); return v >= min && v <= max; }
  catch (NumberFormatException | NullPointerException e) { return false; }
}

Type guard

boolean isRangeFlagValue(String s, int min, int max) {
  return s != null && s.matches("[+-]?[0-9]+")
      && isInRange(s, min, max);
}

Prevention

When it happens

Trigger: Passing a value above the flag's documented maximum to a RangeConverter-backed option, e.g. --test_env=... style counts, verbosity indices beyond the level table, or --jobs=10000 past the cap.

Common situations: Copying aggressive tuning values from blog posts or other machines whose Bazel version allowed a higher cap; values meant for a different flag; automated scripts multiplying defaults by a factor that overshoots the bound.

Related errors


AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14). Data as JSON: /api/errors/e5d89d89f87261eb. Report an issue: GitHub.