bazelbuild/bazel · error · OptionsParsingException
Not a log level: " + input
Error message
Not a log level: " + input
What it means
Thrown by the log-level converter (Converters line 404) when the input is not an integer index into its LEVELS table (an ordered list of java.util.logging levels from most severe to finest). The value is an ordinal like 0..N, not a level name and not an arbitrary number; parse failures and out-of-range indices both surface as this OptionsParsingException.
Source
Thrown at src/main/java/com/google/devtools/common/options/Converters.java:404
public static class LogLevelConverter extends Converter.Contextless<Level> {
static final ImmutableList<Level> LEVELS =
ImmutableList.of(
Level.OFF,
Level.SEVERE,
Level.WARNING,
Level.INFO,
Level.FINE,
Level.FINER,
Level.FINEST);
@Override
public Level convert(String input) throws OptionsParsingException {
try {
int level = Integer.parseInt(input);
return LEVELS.get(level);
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
throw new OptionsParsingException("Not a log level: " + input, e);
}
}
@Override
public String getTypeDescription() {
return "0 <= an integer <= " + (LEVELS.size() - 1);
}
}
/** Checks whether a string is part of a set of strings. */
public static class StringSetConverter extends Converter.Contextless<String> {
private final ImmutableSet<String> values;
public StringSetConverter(String... values) {
this.values = ImmutableSet.copyOf(values);
}
View on GitHub (pinned to e6e199d060)
Solutions
- Pass a plain integer within the range printed by the flag's type description (run bazel help <flag> / --help).
- Lower numbers are more severe; pick 0 for SEVERE-level-only logging and the maximum for FINEST.
- Do not use java.util.logging names; convert them to the ordinal first.
Example fix
# before bazel --my_log_flag=info build //... # after bazel --my_log_flag=2 build //... # 2 maps to INFO in this converter
Defensive patterns
Strategy: validation
Validate before calling
boolean isParsableLogLevel(String s, int maxIndex) {
if (s == null) return false;
try { int i = Integer.parseInt(s); return i >= 0 && i <= maxIndex; }
catch (NumberFormatException e) { return false; }
} Type guard
boolean isLogLevelFlagValue(String s) {
return s != null && s.matches("[0-9]+"); // plus range check against the flag's max
} Prevention
- Map level names to ordinals in your tooling instead of passing names.
- Read the valid range from the flag's type description after Bazel upgrades.
- Validate log-level configs in a preflight check before long builds.
When it happens
Trigger: Passing --verbosity=WARNING, --verbosity=info (level names), --verbosity=-1, or an index past the last level (the type description reports the valid upper bound, e.g. "0 <= an integer <= 5") to a log-level option.
Common situations: Users writing level names because other tools accept them; guessing an index without reading --help for the flag; stale configs from a Bazel version where the table had more/fewer levels.
Related errors
- '" + input + "' is not a boolean
- '" + input + "' is not an int
- '" + input + "' is not a long
- '" + input + "' is not a double
- Not a valid %s: '%s' (should be auto or a boolean)
AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14).
Data as JSON: /api/errors/de2a01d50faef9c7.
Report an issue: GitHub.