bazelbuild/bazel · error · OptionsParsingException

'" + input + "' is not a double

Error message

'" + input + "' is not a double

What it means

Thrown by Converters.DoubleConverter.convert when Double.parseDouble(input) raises NumberFormatException. parseDouble accepts standard floating point including scientific notation and the literals NaN/Infinity, so this error means the string is not a Java-parseable double at all (empty, comma decimal separator, trailing characters).

Source

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

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

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

  /** Standard converter for TriState values. */
  public static class TriStateConverter extends EnumConverter<TriState> {
    public TriStateConverter() {
      super(TriState.class, "tri-state (auto, yes, no) option value");
    }

    @Override
    public TriState convert(@Nullable String input) throws OptionsParsingException {
      if (input == null) {

View on GitHub (pinned to e6e199d060)

Solutions

  1. Pass a plain decimal or scientific literal: --my_ratio=0.5 or --my_ratio=5e-1.
  2. Strip units/percent before passing the value; convert locale separators to '.'.
  3. Ensure the shell variable is quoted so the value arrives intact as one token.

Example fix

# before
bazel build --my_ratio=1,5 //...
# after
bazel build --my_ratio=1.5 //...
Defensive patterns

Strategy: validation

Validate before calling

boolean isParsableDouble(String s) {
  if (s == null || s.isEmpty()) return false;
  try { Double.parseDouble(s); return true; }
  catch (NumberFormatException e) { return false; }
}

Type guard

boolean isDoubleFlagValue(String s) {
  return s != null && s.matches("[+-]?(") /* use isParsableDouble instead; regex is brittle */;
} // prefer validation over regex for doubles

Prevention

When it happens

Trigger: Passing --my_ratio=1,5 (comma), --my_ratio="1.5 ", --my_ratio=", --my_ratio=50% or other non-numeric text to a DoubleConverter-backed option.

Common situations: Locale-formatted numbers pasted from European spreadsheets; percent signs or units left on the value; a typo like 1.5.5; shell quoting that splits the value.

Related errors


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