bazelbuild/bazel · error · OptionsParsingException

'" + input + "' is not a long

Error message

'" + input + "' is not a long

What it means

Thrown by Converters.LongConverter.convert when Long.decode(input) raises NumberFormatException. It mirrors IntegerConverter but for 64-bit long options: hex/octal/decimal literals are accepted by decode(), anything non-conforming is rejected with an OptionsParsingException quoting the input.

Source

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

      } 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);
      }
    }

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

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

View on GitHub (pinned to e6e199d060)

Solutions

  1. Pass a raw integer literal within long range, e.g. --my_long_flag=4294967296.
  2. Express units by choosing the right flag (Duration-typed or byte-size-typed flags) instead of suffixing a long flag.
  3. Quote shell expansions and default empty variables to a valid number.

Example fix

# before
bazel test --my_long_flag=4G //...
# after
bazel test --my_long_flag=4294967296 //...
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

boolean isLongFlagValue(String s) {
  return s != null && s.matches("[+-]?[0-9]+") && !s.toLowerCase(Locale.ROOT).endsWith("l");
}

Prevention

When it happens

Trigger: Passing --my_long_flag=10L, --my_long_flag=2^40, --my_long_flag="" or a value beyond Long range to an option whose converter is LongConverter.

Common situations: Timeouts/byte thresholds configured with units or expressions (e.g. "4G", "10s") on a flag that only takes a raw long; trailing Java-literal L; empty values from unset variables.

Related errors


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