{"record":{"id":"941baf1b2bad9011","repo":"bazelbuild/bazel","slug":"option-lists-a-default-value-s-that-is-not-pars","errorCode":null,"errorMessage":"Option lists a default value (%s) that is not parsable by the option's converter (%s)","messagePattern":"Option lists a default value \\((.+?)\\) that is not parsable by the option's converter \\((.+?)\\)","errorType":"validation","errorClass":"OptionProcessorException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/processor/OptionsClassProcessor.java","lineNumber":625,"sourceCode":"  private void checkForDefaultConverter(\n      ExecutableElement method, List<TypeMirror> acceptedConverterReturnTypes, String defaultValue)\n      throws OptionProcessorException {\n    if (defaultConverters == null) {\n      // Bootstrapping. Do not do this check.\n      return;\n    }\n\n    for (TypeMirror acceptedConverterReturnType : acceptedConverterReturnTypes) {\n      Converter<?> converterInstance = findDefaultConverter(acceptedConverterReturnType);\n      if (converterInstance == null) {\n        continue;\n      }\n      try {\n        converterInstance.convert(defaultValue, null);\n      } catch (OptionsParsingException e) {\n        TypeElement converter =\n            elementUtils.getTypeElement(converterInstance.getClass().getCanonicalName());\n        throw new OptionProcessorException(\n            method,\n            e,\n            \"Option lists a default value (%s) that is not parsable by the option's converter (%s)\",\n            defaultValue,\n            converter);\n      }\n      return;\n    }\n    throw new OptionProcessorException(\n        method,\n        \"Cannot find valid converter for option of type %s\",\n        acceptedConverterReturnTypes.get(0));\n  }\n\n  @Nullable\n  private Converter<?> findDefaultConverter(TypeMirror type) {\n    // According to the documentation of TypeMirror, equality check is not how one checks whether\n    // two instances reference the same type but Types.isSameType().","sourceCodeStart":607,"sourceCodeEnd":643,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/processor/OptionsClassProcessor.java#L607-L643","documentation":"Bazel's options annotation processor validates the defaultValue string of an option by running it through the option's converter at compile time. This error means the converter's convert(defaultValue, null) threw OptionsParsingException — the literal default string cannot be parsed into the option's type.","triggerScenarios":"@Option(defaultValue = \"...\") where the string is malformed for the option's converter — e.g. defaultValue = \"tru\" for a boolean option, \"1.5\" for an Integer-typed option, or an unquoted string missing a required prefix/suffix for a custom converter.","commonSituations":"Typos in default strings; changing an option's type without updating its default; custom converters with strict grammar (e.g. requiring '--flag=value' form or comma-separated lists) where the default was written loosely; note the special string \"null\" means 'no default' and is typically exempt via converter-specific handling.","solutions":["Read the converter named in the message and correct the defaultValue string so the converter accepts it (e.g. \"true\" not \"tru\").","If the default should be 'unset', use the special defaultValue = \"null\".","If you control the converter, either fix the default string or relax/fix the converter's parsing so the documented default parses.","Recompile; the processor re-runs convert() on every build."],"exampleFix":"// before\n@Option(\n  name = \"jobs\",\n  defaultValue = \"auto\",\n  ...\n)\npublic static int jobs;  // int converter cannot parse \"auto\"\n// after\n@Option(\n  name = \"jobs\",\n  defaultValue = \"0\",  // or use a converter/type that accepts \"auto\"\n  ...\n)\npublic static int jobs;","handlingStrategy":"validation","validationCode":"// Verify a default value parses before adding it to the annotation\nstatic <T> String checkDefaultParses(Converter<T> converter, String defaultValue)\n    throws OptionsParsingException {\n  if (!\"null\".equals(defaultValue)) {\n    converter.convert(defaultValue, null); // throws if unparsable\n  }\n  return defaultValue;\n}","typeGuard":null,"tryCatchPattern":"try {\n  converter.convert(candidateDefault, null);\n} catch (OptionsParsingException e) {\n  throw new IllegalArgumentException(\n      \"defaultValue '\" + candidateDefault + \"' rejected by \" + converter.getClass(), e);\n}","preventionTips":["Test each option's default string with its converter when the option is authored (unit test per options class).","Use the exact literals the converter documents (\"true\"/\"false\", decimal ints).","Use \"null\" for 'no default'."],"tags":["java","bazel","annotation-processing","options","compile-time","default-value","converter"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}