bazelbuild/bazel · error · OptionsParsingException
Not a valid %s: '%s' (should be auto or a boolean)
Error message
Not a valid %s: '%s' (should be auto or a boolean)
What it means
Thrown by the TriState converter (Converters line 174) when the input is neither "auto" nor one of the accepted boolean spellings (true/1/yes/t/y, false/0/no/f/n, case-insensitive). TriState options distinguish "explicitly on", "explicitly off", and "not set / automatic", so arbitrary strings are rejected at parse time.
Source
Thrown at src/main/java/com/google/devtools/common/options/Converters.java:174
super(TriState.class, "tri-state (auto, yes, no) option value");
}
@Override
public TriState convert(@Nullable String input) throws OptionsParsingException {
if (input == null) {
return TriState.AUTO;
}
input = Ascii.toLowerCase(input);
if (input.equals("auto")) {
return TriState.AUTO;
}
if (ENABLED_REPS.contains(input)) {
return TriState.YES;
}
if (DISABLED_REPS.contains(input)) {
return TriState.NO;
}
throw new OptionsParsingException(
"Not a valid %s: '%s' (should be auto or a boolean)".formatted(typeName, input));
}
@Override
public String getTypeDescription() {
return "a tri-state (auto, yes, no)";
}
}
/**
* Standard "converter" for Void. Should not actually be invoked. For instance, expansion flags
* are usually Void-typed and do not invoke the converter.
*/
public static class VoidConverter extends Converter.Contextless<Void> {
@Override
public Void convert(String input) throws OptionsParsingException {
if (input == null || input.equals("null")) {
return null; // expected input, return is unused so null is fine.View on GitHub (pinned to e6e199d060)
Solutions
- Use auto to let the flag decide automatically, or one of the boolean spellings (e.g. yes/no) for an explicit choice.
- To unset a TriState flag, simply omit it from the command line or use auto.
- Update stale scripts that still write on/off.
Example fix
# before bazel build --my_tristate=on //... # after bazel build --my_tristate=yes //...
Defensive patterns
Strategy: validation
Validate before calling
boolean isParsableTriState(String s) {
if (s == null) return false;
String v = s.toLowerCase(Locale.ROOT);
return v.equals("auto")
|| Set.of("true","1","yes","t","y","false","0","no","f","n").contains(v);
} Type guard
boolean isTriStateFlagValue(String s) {
return s != null && s.matches("(?i)(auto|true|false|1|0|yes|no|t|f|y|n)");
} Prevention
- Use auto rather than empty values to reset TriState flags.
- Keep on/off out of generated configs for TriState flags.
- Encode the allowed spellings in one shared constant used by both docs and scripts.
When it happens
Trigger: Passing --my_tristate=maybe, --my_tristate=unset, or --my_tristate="" to a TriState-typed option; also passing on/off which this converter does not accept.
Common situations: Users assuming on/off works because other tools accept it; trying to "reset" a flag by giving an empty value instead of auto; script defaults that fall back to an invalid token.
Related errors
- '" + input + "' is not a boolean
- '" + input + "' is not an int
- '" + input + "' is not a long
- '" + input + "' is not a double
- '" + input + "' unexpected
AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14).
Data as JSON: /api/errors/69eb8103ff7fbb52.
Report an issue: GitHub.