bazelbuild/bazel · error · OptionsParsingException

'" + input + "' is not an int

Error message

'" + input + "' is not an int

What it means

Thrown by Converters.IntegerConverter.convert when Integer.decode(input) raises NumberFormatException. decode() accepts decimal literals, 0x/#-prefixed hex, and 0-prefixed octal, but rejects everything else; the converter wraps the failure in an OptionsParsingException that names the offending input.

Source

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

        return null;
      }
      return input;
    }

    @Override
    public String getTypeDescription() {
      return "a string; empty to unset";
    }
  }

  /** Standard converter for integers. */
  public static class IntegerConverter extends Converter.Contextless<Integer> {
    @Override
    public Integer convert(String input) throws OptionsParsingException {
      try {
        return Integer.decode(input);
      } catch (NumberFormatException e) {
        throw new OptionsParsingException("'" + input + "' is not an int", e);
      }
    }

    @Override
    public String getTypeDescription() {
      return "an integer";
    }
  }

  /** Standard converter for longs. */
  public static class LongConverter extends Converter.Contextless<Long> {
    @Override
    public Long convert(String input) throws OptionsParsingException {
      try {
        return Long.decode(input);
      } catch (NumberFormatException e) {
        throw new OptionsParsingException("'" + input + "' is not a long", e);
      }

View on GitHub (pinned to e6e199d060)

Solutions

  1. Pass a plain decimal integer within int range, e.g. --jobs=1500.
  2. Remove separators and unit suffixes from the value.
  3. If the flag legitimately takes values beyond Integer.MAX_VALUE, check whether a long-typed flag/converter exists for it.

Example fix

# before
bazel build --jobs=1,500 //...
# after
bazel build --jobs=1500 //...
Defensive patterns

Strategy: validation

Validate before calling

boolean isParsableInt(String s) {
  if (s == null) return false;
  try { Integer.decode(s); return true; }
  catch (NumberFormatException e) { return false; }
}

Type guard

boolean isIntFlagValue(String s) {
  return s != null && s.matches("[+-]?(0x[0-9a-fA-F]+|0[0-7]*|[1-9][0-9]*)");
}

Prevention

When it happens

Trigger: Passing --jobs=1.5, --jobs=1,000, --jobs="" (empty), --jobs=10L, or a value outside Integer range such as --jobs=99999999999 to an option using IntegerConverter.

Common situations: Localized number formats (thousands separators, comma decimal); copying Java literals (10L, 0xFF then mistyped as FF); values sized for a long passed to an int option; unset shell variables expanding to empty.

Related errors


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