{"record":{"id":"3608aaee2365b6f6","repo":"bazelbuild/bazel","slug":"failed-to-parse-caffeinespec-e-getmessage","errorCode":null,"errorMessage":"Failed to parse CaffeineSpec: \" + e.getMessage()","messagePattern":"Failed to parse CaffeineSpec: \" \\+ e\\.getMessage\\(\\)","errorType":"validation","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/Converters.java","lineNumber":667,"sourceCode":"    @Override\n    public OptionalInt convert(String input) throws OptionsParsingException {\n      return input.equals(UNSET)\n          ? OptionalInt.empty()\n          : OptionalInt.of(PERCENTAGE_CONVERTER.convert(input));\n    }\n  }\n\n  /**\n   * A {@link Converter} for {@link com.github.benmanes.caffeine.cache.CaffeineSpec}. The spec may\n   * be empty, in which case this converter returns null.\n   */\n  public static final class CaffeineSpecConverter extends Converter.Contextless<CaffeineSpec> {\n    @Override\n    public CaffeineSpec convert(String spec) throws OptionsParsingException {\n      try {\n        return CaffeineSpec.parse(spec);\n      } catch (IllegalArgumentException e) {\n        throw new OptionsParsingException(\"Failed to parse CaffeineSpec: \" + e.getMessage(), e);\n      }\n    }\n\n    @Override\n    public String getTypeDescription() {\n      return \"Converts to a CaffeineSpec, or null if the input is empty\";\n    }\n  }\n\n  /** A {@link Converter} for a size in bytes with an optional multiplier suffix. */\n  public static final class ByteSizeConverter extends Converter.Contextless<Long> {\n    private static final Pattern PATTERN =\n        Pattern.compile(\"(?<value>[0-9]+)(?<multiplier>[KMGT]?)\");\n\n    private static final ImmutableMap<String, Long> MULTIPLIER_MAP =\n        ImmutableMap.of(\n            \"K\",\n            1024L,","sourceCodeStart":649,"sourceCodeEnd":685,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/Converters.java#L649-L685","documentation":"Thrown by CaffeineSpecConverter when CaffeineSpec.parse(spec) raises IllegalArgumentException, i.e. the string is not a valid Caffeine cache specification. CaffeineSpec has its own strict grammar (keys like maximumSize, expireAfterAccess with '=' pairs separated by ','); any syntax or unknown-key error is wrapped into an OptionsParsingException with the underlying reason appended.","triggerScenarios":"Passing a malformed spec to a flag typed CaffeineSpecConverter, e.g. --experimental_repository_cache_hard_limit=100MB (wrong unit grammar), maximumSize=abc, spec with unknown option key, or missing '=' in a key-value pair. The empty string is valid and returns null.","commonSituations":"Confusing Caffeine spec syntax with byte-size syntax (using '1G' where Caffeine expects a plain number for maximumSize), typos in spec keys, using a newer/older flag name whose accepted keys changed between Bazel versions.","solutions":["Read the appended e.getMessage() from Caffeine — it states the exact parse failure position and expected grammar.","Correct the spec to Caffeine grammar: comma-separated key=value pairs, e.g. maximumSize=512,expireAfterAccess=3600s.","For size-style flags, use ByteSizeConverter-typed flags (e.g. '1G', '512M') instead of Caffeine-spec flags; check the flag's getTypeDescription().","If the spec should be empty/default, pass an empty value rather than a placeholder like 'default'."],"exampleFix":"# before\n--experimental_action_cache=100MB\n\n# after\n--experimental_action_cache=maximumSize=104857600","handlingStrategy":"validation","validationCode":"// Pre-flight the spec with Caffeine itself before handing it to the flag\ntry {\n  com.github.benmanes.caffeine.cache.CaffeineSpec.parse(spec);\n} catch (IllegalArgumentException e) {\n  throw new IllegalArgumentException(\"Bad cache spec '\" + spec + \"': \" + e.getMessage(), e);\n}","typeGuard":null,"tryCatchPattern":"Catch OptionsParsingException; the wrapped cause is the original IllegalArgumentException from Caffeine — read e.getCause().getMessage() for the precise parse failure and fix the spec string.","preventionTips":["Consult Caffeine's spec grammar (key=value pairs, comma-separated) before writing the flag","Do not reuse ByteSize-style values (1G) for Caffeine-spec flags","Pin spec examples that pass CaffeineSpec.parse() in your config templates"],"tags":["options-parsing","caffeine","cache","converter","bazel"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}