{"record":{"id":"6a44dce2db6cca8d","repo":"bazelbuild/bazel","slug":"not-one-of-values","errorCode":null,"errorMessage":"Not one of \" + values","messagePattern":"Not one of \" \\+ values","errorType":"validation","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/Converters.java","lineNumber":429,"sourceCode":"    }\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\n    @Override\n    public String convert(String input) throws OptionsParsingException {\n      if (values.contains(input)) {\n        return input;\n      }\n\n      throw new OptionsParsingException(\"Not one of \" + values);\n    }\n\n    @Override\n    public String getTypeDescription() {\n      return joinEnglishList(values);\n    }\n  }\n\n  /** Checks whether a string is a valid regex pattern and compiles it. */\n  public static class RegexPatternConverter extends Converter.Contextless<RegexPatternOption> {\n\n    @Override\n    public RegexPatternOption convert(String input) throws OptionsParsingException {\n      try {\n        return RegexPatternOption.create(\n            Pattern.compile(StringEncoding.internalToUnicode(input), Pattern.DOTALL));\n      } catch (PatternSyntaxException e) {\n        throw new OptionsParsingException(\"Not a valid regular expression: \" + e.getMessage());","sourceCodeStart":411,"sourceCodeEnd":447,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/Converters.java#L411-L447","documentation":"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.","triggerScenarios":"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.","commonSituations":"Typos and case mismatches; values valid in an older/newer Bazel version removed or renamed; scripts constructing values dynamically that sometimes produce empty strings.","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."],"exampleFix":"# before\nbazel build --strategy=Local //...\n# after\nbazel build --strategy=local //...   # match exact spelling/case from the error's value list","handlingStrategy":"validation","validationCode":"boolean isAllowedValue(String input, Set<String> allowed) {\n  return input != null && allowed.contains(input); // exact, case-sensitive match\n}","typeGuard":"boolean isEnumSetFlagValue(String s, java.util.Set<String> allowed) {\n  return s != null && allowed.contains(s);\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["bazel","options","converter","enum","cli"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}