{"record":{"id":"57ad88697cb9692f","repo":"bazelbuild/bazel","slug":"input-unexpected","errorCode":null,"errorMessage":"'\" + input + \"' unexpected","messagePattern":"'\" \\+ input \\+ \"' unexpected","errorType":"validation","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/Converters.java","lineNumber":194,"sourceCode":"    }\n\n    @Override\n    public String getTypeDescription() {\n      return \"a tri-state (auto, yes, no)\";\n    }\n  }\n\n  /**\n   * Standard \"converter\" for Void. Should not actually be invoked. For instance, expansion flags\n   * are usually Void-typed and do not invoke the converter.\n   */\n  public static class VoidConverter extends Converter.Contextless<Void> {\n    @Override\n    public Void convert(String input) throws OptionsParsingException {\n      if (input == null || input.equals(\"null\")) {\n        return null; // expected input, return is unused so null is fine.\n      }\n      throw new OptionsParsingException(\"'\" + input + \"' unexpected\");\n    }\n\n    @Override\n    public String getTypeDescription() {\n      return \"\";\n    }\n  }\n\n  /** Standard converter for the {@link java.time.Duration} type. */\n  public static class DurationConverter extends Converter.Contextless<Duration> {\n    private static final Pattern DURATION_REGEX = Pattern.compile(\"^([0-9]+)(d|h|m|s|ms|ns)$\");\n\n    @Override\n    public Duration convert(String input) throws OptionsParsingException {\n      // To be compatible with the previous parser, '0' doesn't need a unit.\n      if (\"0\".equals(input)) {\n        return Duration.ZERO;\n      }","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/Converters.java#L176-L212","documentation":"Thrown by Converters.VoidConverter.convert when it receives any input other than null or the literal string \"null\". Void-typed options (typically expansion flags that only expand into other flags) carry no value, so their converter is never supposed to see real data; a non-empty value means the flag was used incorrectly.","triggerScenarios":"Passing --my_expansion_flag=anything (equals form with a value) or --my_expansion_flag value (space form) where the option is annotated with converter = VoidConverter.class.","commonSituations":"Users adding =true to an expansion/alias flag out of habit; tools that always emit --flag=value syntax regardless of the flag type; copy-pasting from docs of a different flag that does take a value.","solutions":["Pass the flag bare with no value: --my_expansion_flag.","Check the flag's documentation/type description (empty string means no value expected).","If you need a parameterized variant, it must be a separate flag with a real converter, not the Void-typed expansion flag."],"exampleFix":"# before\nbazel build --experimental_expansion_flag=true //...\n# after\nbazel build --experimental_expansion_flag //...","handlingStrategy":"validation","validationCode":"// Void/expansion flags take no value: reject before parsing\nfor (String arg : args) {\n  if (VOID_FLAG_NAMES.stream().anyMatch(arg::startsWith)\n      && (arg.contains(\"=\") && !arg.endsWith(\"=null\"))) {\n    throw new IllegalArgumentException(\"Flag takes no value: \" + arg);\n  }\n}","typeGuard":"boolean isBareVoidFlag(String arg, Set<String> voidFlags) {\n  return voidFlags.contains(arg); // exactly the bare name, no '=' and no value token\n}","tryCatchPattern":null,"preventionTips":["Learn which flags are expansion flags from --help; pass them bare.","Do not template flags as --flag=value unconditionally in generated command lines.","Treat \"'X' unexpected\" from VoidConverter as a usage bug in the caller, not a data problem."],"tags":["bazel","options","converter","void","expansion-flag","cli"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}