{"record":{"id":"de2a01d50faef9c7","repo":"bazelbuild/bazel","slug":"not-a-log-level-input","errorCode":null,"errorMessage":"Not a log level: \" + input","messagePattern":"Not a log level: \" \\+ input","errorType":"validation","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/Converters.java","lineNumber":404,"sourceCode":"  public static class LogLevelConverter extends Converter.Contextless<Level> {\n\n    static final ImmutableList<Level> LEVELS =\n        ImmutableList.of(\n            Level.OFF,\n            Level.SEVERE,\n            Level.WARNING,\n            Level.INFO,\n            Level.FINE,\n            Level.FINER,\n            Level.FINEST);\n\n    @Override\n    public Level convert(String input) throws OptionsParsingException {\n      try {\n        int level = Integer.parseInt(input);\n        return LEVELS.get(level);\n      } catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {\n        throw new OptionsParsingException(\"Not a log level: \" + input, e);\n      }\n    }\n\n    @Override\n    public String getTypeDescription() {\n      return \"0 <= an integer <= \" + (LEVELS.size() - 1);\n    }\n  }\n\n  /** Checks whether a string is part of a set of strings. */\n  public static class StringSetConverter extends Converter.Contextless<String> {\n\n    private final ImmutableSet<String> values;\n\n    public StringSetConverter(String... values) {\n      this.values = ImmutableSet.copyOf(values);\n    }\n","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/Converters.java#L386-L422","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nbazel --my_log_flag=info build //...\n# after\nbazel --my_log_flag=2 build //...   # 2 maps to INFO in this converter","handlingStrategy":"validation","validationCode":"boolean isParsableLogLevel(String s, int maxIndex) {\n  if (s == null) return false;\n  try { int i = Integer.parseInt(s); return i >= 0 && i <= maxIndex; }\n  catch (NumberFormatException e) { return false; }\n}","typeGuard":"boolean isLogLevelFlagValue(String s) {\n  return s != null && s.matches(\"[0-9]+\"); // plus range check against the flag's max\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["bazel","options","converter","logging","cli"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}