{"record":{"id":"ace7245c68f2e739","repo":"bazelbuild/bazel","slug":"empty-values-are-not-allowed-as-part-of-this-g","errorCode":null,"errorMessage":"Empty values are not allowed as part of this \" + getTypeDescription()","messagePattern":"Empty values are not allowed as part of this \" \\+ getTypeDescription\\(\\)","errorType":"validation","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/Converters.java","lineNumber":303,"sourceCode":"    protected SeparatedOptionListConverter(\n        char separator, String separatorDescription, boolean allowEmptyValues) {\n      this.separatorDescription = separatorDescription;\n      this.splitter = Splitter.on(separator);\n      this.allowEmptyValues = allowEmptyValues;\n    }\n\n    @Override\n    public ImmutableList<String> convert(String input) throws OptionsParsingException {\n      ImmutableList<String> result =\n          input.isEmpty() ? ImmutableList.of() : ImmutableList.copyOf(splitter.split(input));\n      if (!allowEmptyValues && result.contains(\"\")) {\n        // If the list contains exactly the empty string, it means an empty value was passed and we\n        // should instead return an empty list.\n        if (result.size() == 1) {\n          return ImmutableList.of();\n        }\n\n        throw new OptionsParsingException(\n            \"Empty values are not allowed as part of this \" + getTypeDescription());\n      }\n      return result;\n    }\n\n    @Override\n    public String getTypeDescription() {\n      return separatorDescription + \"-separated list of options\";\n    }\n  }\n\n  /**\n   * Converter for options separated by some separator character, where order and count do not\n   * matter, i.e. semantically it is a set, not a list.\n   */\n  public static class SeparatedOptionSetConverter extends SeparatedOptionListConverter {\n    private final String separatorDescription;\n","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/Converters.java#L285-L321","documentation":"Thrown by the list converter in Converters (line 303) when the split of a comma/space-separated option value yields an empty element in a multi-element list and the converter was built with allowEmptyValues=false. A value that is exactly one empty string is tolerated (treated as the empty list), but embedded empties like \"a,,b\" are rejected.","triggerScenarios":"Passing --my_list=a,,b or --my_list=,x (leading/trailing separator producing an empty first/last element in a list of size > 1) to an option using this converter with empty values disallowed.","commonSituations":"Comma-joined shell variables where one element is empty (JOIN=\"$A,$B\" with A unset); trailing separators left by scripts; cleanup logic that produces consecutive separators.","solutions":["Remove empty segments from the value: --my_list=a,b.","Sanitize before passing: strip leading/trailing separators and collapse doubled ones.","If empty entries are meaningful, use or request a converter constructed with allowEmptyValues=true."],"exampleFix":"# before\nbazel build --my_list=$A,$B   # A unset -> \",b\"\n# after\nLIST=$(printf '%s\\n' \"$A\" \"$B\" | grep -v '^$' | paste -sd, -)\nbazel build --my_list=$LIST","handlingStrategy":"validation","validationCode":"boolean hasNoEmptySegments(String listValue, char sep) {\n  if (listValue.isEmpty()) return true; // single empty is tolerated\n  for (String part : listValue.split(Pattern.quote(String.valueOf(sep)), -1)) {\n    if (part.isEmpty()) return false;\n  }\n  return true;\n}","typeGuard":"boolean isCleanListValue(String v) {\n  return v != null && !v.startsWith(\",\") && !v.endsWith(\",\") && !v.contains(\",,\");\n}","tryCatchPattern":null,"preventionTips":["Build list values by joining only non-empty elements.","Trim and collapse doubled separators before passing flags.","Prefer repeating the flag (--my_list=a --my_list=b) over comma strings where supported."],"tags":["bazel","options","converter","list","cli"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}