{"record":{"id":"c1a30cb4f7edbff4","repo":"bazelbuild/bazel","slug":"while-parsing-option-s-s","errorCode":null,"errorMessage":"While parsing option %s: %s","messagePattern":"While parsing option (.+?): (.+?)","errorType":"exception","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/ParsedOptionDescription.java","lineNumber":214,"sourceCode":"  @Nullable\n  ParsedOptionDescription getExpandedFrom() {\n    return origin.getExpandedFrom();\n  }\n\n  public boolean isExplicit() {\n    return origin.getExpandedFrom() == null\n        && origin.getImplicitDependent() == null\n        // Exclude options from PROJECT.scl files, which are not considered explicit.\n        && !(origin.getSource() != null && origin.getSource().endsWith(\"PROJECT.scl\"));\n  }\n\n  public Object getConvertedValue() throws OptionsParsingException {\n    Converter<?> converter = optionDefinition.getConverter();\n    try {\n      return converter.convert(unconvertedValue, conversionContext);\n    } catch (OptionsParsingException e) {\n      // The converter doesn't know the option name, so we supply it here by re-throwing:\n      throw new OptionsParsingException(\n          String.format(\"While parsing option %s: %s\", commandLineForm, e.getMessage()), e);\n    }\n  }\n\n  @Override\n  public String toString() {\n    // Check that a dummy value-less option instance does not output all the default information.\n    if (commandLineForm == null) {\n      return optionDefinition.toString();\n    }\n    String source = origin.getSource();\n    return String.format(\n        \"option '%s'%s\",\n        commandLineForm, source == null ? \"\" : String.format(\" (source %s)\", source));\n  }\n}\n","sourceCodeStart":196,"sourceCodeEnd":231,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/ParsedOptionDescription.java#L196-L231","documentation":"ParsedOptionDescription.getConvertedValue wraps any OptionsParsingException thrown by the option's Converter during convert(): converters only see the raw string and cannot know which flag they are converting for, so the option's command-line form is prepended to give context. The original converter message (e.g. 'not a boolean', 'not a valid integer', 'not a boolean') is preserved in the wrapped text and cause.","triggerScenarios":"Any value-conversion failure: `--jobs=abc` (int converter), `--stamp=maybe` (tri-state converter), `--disk_cache=/root/x` (filesystem checks inside converters), invalid regex/enum/path values — every flag whose Converter.convert throws.","commonSituations":"Wrong value type from CI variables (unquoted empty strings, 'True' vs 'true'); path converters hitting inaccessible directories; enum converters receiving values valid in an older Bazel version.","solutions":["Read the suffix after the colon — it is the converter's own reason (e.g. 'not a valid integer') and names what the flag actually expects","Check `bazel help <command>` for the flag's expected value format and correct the value","For custom converters in your own options, make the Converter's exception message state the expected format so this wrapper is self-explanatory"],"exampleFix":"# before\nbazel build --jobs=lots //...\n# after\nbazel build --jobs=16 //...","handlingStrategy":"try-catch","validationCode":"// For custom converters: front-load validation so convert() rarely throws\nnew Converter<String>() {\n  public String convert(String input, Object ctx) throws OptionsParsingException {\n    if (!input.matches(\"[a-z]+\")) {\n      throw new OptionsParsingException(\"expected lowercase word, got '\" + input + \"'\");\n    }\n    return input;\n  }\n}","typeGuard":null,"tryCatchPattern":"Catch OptionsParsingException from getConvertedValue()/parse and parse out the 'While parsing option <form>:' prefix to attribute the failure to the exact flag in user-facing logs.","preventionTips":["Validate flag values in wrapper scripts before invoking Bazel","Give custom converters precise error messages naming the expected format","Quote CI-provided values and reject empty strings for typed flags"],"tags":["bazel","options","converter","flag-value","flag-parsing"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}