bazelbuild/bazel · error · AssertionError
Failed to parse input: "%s"
Error message
Failed to parse input: "%s"
What it means
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.
Source
Thrown at src/main/java/com/google/devtools/common/options/testing/ConverterTester.java:103
* <li>to an instance of an arbitrary class
* <li>to any values converted from inputs in a different addEqualityGroup call
* </ul>
*
* @throws AssertionError if an {@link OptionsParsingException} is thrown from the {@link
* Converter#convert} method when converting any of the inputs.
* @see EqualsTester#addEqualityGroup
*/
@CanIgnoreReturnValue
public ConverterTester addEqualityGroup(String... inputs) {
ImmutableList.Builder<WrappedItem> wrapped = ImmutableList.builder();
ImmutableList<String> inputList = ImmutableList.copyOf(inputs);
inputLists.add(inputList);
for (String input : inputList) {
testedInputs.add(input);
try {
wrapped.add(new WrappedItem(input, converter.convert(input, conversionContext)));
} catch (OptionsParsingException ex) {
throw new AssertionError("Failed to parse input: \"" + input + "\"", ex);
}
}
tester.addEqualityGroup(wrapped.build().toArray());
return this;
}
/**
* Tests the convert method of the wrapped Converter class, verifying the properties listed in the
* Javadoc listed for {@link #addEqualityGroup}.
*
* @throws AssertionError if one of the expected properties did not hold up
* @see EqualsTester#testEquals
*/
@CanIgnoreReturnValue
public ConverterTester testConvert() {
tester.testEquals();
testItems();
return this;View on GitHub (pinned to e6e199d060)
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.
Example fix
// before
tester.addEqualityGroup("not-a-number"); // int converter throws
// after
assertThat(convert("not-a-number", context)).failsWith(OptionsParsingException.class); Defensive patterns
Strategy: validation
Validate before calling
// Optionally probe an input before grouping it
static boolean parses(Converter<?> c, String input, Object ctx) {
try { c.convert(input, ctx); return true; }
catch (OptionsParsingException e) { return false; }
}
if (parses(converter, input, context)) { tester.addEqualityGroup(input); } Try / catch
try { tester.addEqualityGroup(input); } catch (AssertionError e) { if (!(e.getCause() instanceof OptionsParsingException)) throw e; /* record as known-invalid input */ } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to create converter
- '" + input + "' is not a boolean
- '" + input + "' is not an int
- '" + input + "' is not a long
- '" + input + "' is not a double
AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14).
Data as JSON: /api/errors/886dc6a62209a585.
Report an issue: GitHub.