bazelbuild/bazel · error · OptionsParsingException
Not one of " + values
Error message
Not one of " + values
What it means
Thrown by Converters.StringSetConverter.convert when the input is not one of the exact strings the converter was constructed with. Many enum-like Bazel flags are implemented as a closed set of allowed strings; anything not in that ImmutableSet is rejected with a message that conveniently lists all valid values.
Source
Thrown at src/main/java/com/google/devtools/common/options/Converters.java:429
}
}
/** 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);
}
@Override
public String convert(String input) throws OptionsParsingException {
if (values.contains(input)) {
return input;
}
throw new OptionsParsingException("Not one of " + values);
}
@Override
public String getTypeDescription() {
return joinEnglishList(values);
}
}
/** Checks whether a string is a valid regex pattern and compiles it. */
public static class RegexPatternConverter extends Converter.Contextless<RegexPatternOption> {
@Override
public RegexPatternOption convert(String input) throws OptionsParsingException {
try {
return RegexPatternOption.create(
Pattern.compile(StringEncoding.internalToUnicode(input), Pattern.DOTALL));
} catch (PatternSyntaxException e) {
throw new OptionsParsingException("Not a valid regular expression: " + e.getMessage());View on GitHub (pinned to e6e199d060)
Solutions
- Use one of the values listed verbatim in the error message ("Not one of [a, b]").
- Check the flag's help text (its type description lists the same values) after upgrading Bazel.
- Parameterize scripts from the same constant list the flag defines to prevent drift.
Example fix
# before bazel build --strategy=Local //... # after bazel build --strategy=local //... # match exact spelling/case from the error's value list
Defensive patterns
Strategy: validation
Validate before calling
boolean isAllowedValue(String input, Set<String> allowed) {
return input != null && allowed.contains(input); // exact, case-sensitive match
} Type guard
boolean isEnumSetFlagValue(String s, java.util.Set<String> allowed) {
return s != null && allowed.contains(s);
} Prevention
- Derive script constants from the flag's documented value list.
- The error message lists every valid value; read it before retrying.
- Re-verify closed-set values after Bazel version upgrades.
When it happens
Trigger: Passing --my_flag=compresse to a flag whose StringSetConverter was built with {"compressed","uncompressed"}; passing values with different casing, whitespace, or an equals-sign variant not in the set.
Common situations: Typos and case mismatches; values valid in an older/newer Bazel version removed or renamed; scripts constructing values dynamically that sometimes produce empty strings.
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/6a44dce2db6cca8d.
Report an issue: GitHub.