{"record":{"id":"5b58065be5034b22","repo":"bazelbuild/bazel","slug":"input-is-not-a-boolean","errorCode":null,"errorMessage":"'\" + input + \"' is not a boolean","messagePattern":"'\" \\+ input \\+ \"' is not a boolean","errorType":"validation","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/Converters.java","lineNumber":58,"sourceCode":"\n  private static final ImmutableSet<String> DISABLED_REPS =\n      ImmutableSet.of(\"false\", \"0\", \"no\", \"f\", \"n\");\n\n  /** Standard converter for booleans. Accepts common shorthands/synonyms. */\n  public static class BooleanConverter extends Converter.Contextless<Boolean> {\n    @Override\n    public Boolean convert(String input) throws OptionsParsingException {\n      if (input == null) {\n        return false;\n      }\n      input = Ascii.toLowerCase(input);\n      if (ENABLED_REPS.contains(input)) {\n        return true;\n      }\n      if (DISABLED_REPS.contains(input)) {\n        return false;\n      }\n      throw new OptionsParsingException(\"'\" + input + \"' is not a boolean\");\n    }\n\n    @Override\n    public String getTypeDescription() {\n      return \"a boolean\";\n    }\n  }\n\n  /** Standard converter for Strings. */\n  public static class StringConverter extends Converter.Contextless<String> {\n    @Override\n    public String convert(String input) {\n      return input;\n    }\n\n    @Override\n    public String getTypeDescription() {\n      return \"a string\";","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/Converters.java#L40-L76","documentation":"Thrown by Converters.BooleanConverter.convert when the input string (after lowercasing) is not one of the accepted boolean spellings. The converter deliberately accepts several synonyms: true/1/yes/t/y for true and false/0/no/f/n for false, anything else is rejected at option-parsing time with an OptionsParsingException.","triggerScenarios":"Passing a flag value such as --my_flag=on, --my_flag=enabled, --my_flag=\"\" or --my_flag=truee to any option whose converter is BooleanConverter (the default for boolean flags using this converter).","commonSituations":"Copy-pasting config from other tools that accept on/off or enabled/disabled; empty variable expansion producing --my_flag=; quoting mistakes that leave trailing whitespace or a stray character on the value.","solutions":["Use one of the accepted spellings: true/1/yes/t/y or false/0/no/f/n (case-insensitive).","If the value comes from a shell variable, default it: --my_flag=${MY_FLAG:-false}.","Prefer the bare --my_flag / --no_my_flag forms for boolean flags when the parser supports them."],"exampleFix":"# before\nbazel build --experimental_new_flag=on //...\n# after\nbazel build --experimental_new_flag=yes //...","handlingStrategy":"validation","validationCode":"private static final Set<String> BOOLS = Set.of(\n    \"true\",\"1\",\"yes\",\"t\",\"y\",\"false\",\"0\",\"no\",\"f\",\"n\");\n\nboolean isParsableBoolean(String s) {\n  return s != null && BOOLS.contains(s.toLowerCase(Locale.ROOT));\n}","typeGuard":"boolean isBooleanFlagValue(String s) {\n  return s != null && s.matches(\"(?i)(true|false|1|0|yes|no|t|f|y|n)\");\n}","tryCatchPattern":"try {\n  optionsParser.parse(OptionFiltering.ONLY); // or your parse entry point\n} catch (OptionsParsingException e) {\n  if (e.getMessage().endsWith(\"is not a boolean\")) { /* tell user accepted spellings */ }\n}","preventionTips":["Document accepted boolean spellings next to custom flags.","Default boolean values from scripts with ${VAR:-false} instead of passing raw variables.","Reject on/off at your config layer if your tooling generates them."],"tags":["bazel","options","converter","boolean","cli"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}