{"record":{"id":"886dc6a62209a585","repo":"bazelbuild/bazel","slug":"failed-to-parse-input-s","errorCode":null,"errorMessage":"Failed to parse input: \"%s\"","messagePattern":"Failed to parse input: \"(.+?)\"","errorType":"exception","errorClass":"AssertionError","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/testing/ConverterTester.java","lineNumber":103,"sourceCode":"   *   <li>to an instance of an arbitrary class\n   *   <li>to any values converted from inputs in a different addEqualityGroup call\n   * </ul>\n   *\n   * @throws AssertionError if an {@link OptionsParsingException} is thrown from the {@link\n   *     Converter#convert} method when converting any of the inputs.\n   * @see EqualsTester#addEqualityGroup\n   */\n  @CanIgnoreReturnValue\n  public ConverterTester addEqualityGroup(String... inputs) {\n    ImmutableList.Builder<WrappedItem> wrapped = ImmutableList.builder();\n    ImmutableList<String> inputList = ImmutableList.copyOf(inputs);\n    inputLists.add(inputList);\n    for (String input : inputList) {\n      testedInputs.add(input);\n      try {\n        wrapped.add(new WrappedItem(input, converter.convert(input, conversionContext)));\n      } catch (OptionsParsingException ex) {\n        throw new AssertionError(\"Failed to parse input: \\\"\" + input + \"\\\"\", ex);\n      }\n    }\n    tester.addEqualityGroup(wrapped.build().toArray());\n    return this;\n  }\n\n  /**\n   * Tests the convert method of the wrapped Converter class, verifying the properties listed in the\n   * Javadoc listed for {@link #addEqualityGroup}.\n   *\n   * @throws AssertionError if one of the expected properties did not hold up\n   * @see EqualsTester#testEquals\n   */\n  @CanIgnoreReturnValue\n  public ConverterTester testConvert() {\n    tester.testEquals();\n    testItems();\n    return this;","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/testing/ConverterTester.java#L85-L121","documentation":"Thrown when ConverterTester.addEqualityGroup calls converter.convert(input, conversionContext) and the converter rejects the input with OptionsParsingException. The test author supplied an input string that the converter under test cannot parse, so the equality group cannot be built.","triggerScenarios":"Passing a malformed input to addEqualityGroup, e.g. an empty string to a converter that requires a value, a non-integer to an integer converter, or an unknown enum constant; using a conversionContext the converter rejects.","commonSituations":"Copy-pasting test inputs from another converter's test; converter syntax changed (e.g. label parsing now requires a leading '//'); null context passed where converter dereferences it.","solutions":["Fix the test input so the converter accepts it (match the converter's documented syntax).","If the input is intentionally invalid, do not add it to an equality group — test rejection separately by calling converter.convert directly and asserting the OptionsParsingException.","Check the conversionContext passed to the ConverterTester constructor is one the converter expects.","Update inputs after changing the converter's accepted grammar."],"exampleFix":"// before\ntester.addEqualityGroup(\"not-a-number\"); // int converter throws\n\n// after\nassertThat(convert(\"not-a-number\", context)).failsWith(OptionsParsingException.class);","handlingStrategy":"validation","validationCode":"// Optionally probe an input before grouping it\nstatic boolean parses(Converter<?> c, String input, Object ctx) {\n  try { c.convert(input, ctx); return true; }\n  catch (OptionsParsingException e) { return false; }\n}\n\nif (parses(converter, input, context)) { tester.addEqualityGroup(input); }","typeGuard":null,"tryCatchPattern":"try { tester.addEqualityGroup(input); } catch (AssertionError e) { if (!(e.getCause() instanceof OptionsParsingException)) throw e; /* record as known-invalid input */ }","preventionTips":["Test invalid inputs with direct convert() calls asserting OptionsParsingException, not via addEqualityGroup.","Keep a reference of each converter's accepted syntax next to its test.","Re-run converter tests whenever the accepted grammar changes."],"tags":["testing","converter","options","parsing"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}