oracle/graal · error · InvalidArgumentException
The argument '%s' could not be parsed: expected true or fals
Error message
The argument '%s' could not be parsed: expected true or false
What it means
Thrown by BooleanArgument.parseValue when the value string is not 'true' or 'false' (case-insensitive). BooleanArgument is a ValuedArgument<Boolean>, so any other spelling — 'yes', '1', 'on' — is rejected. Surfaces as InvalidArgumentException('The argument X could not be parsed: expected true or false').
Source
Thrown at compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/args/BooleanArgument.java:42
*/
package org.graalvm.profdiff.args;
/**
* A program argument that holds a boolean.
*/
public class BooleanArgument extends ValuedArgument<Boolean> {
public BooleanArgument(String name, boolean defaultValue, String help) {
super(name, defaultValue, help);
}
@Override
protected Boolean parseValue(String s) throws InvalidArgumentException {
if (s.equalsIgnoreCase("true")) {
return true;
} else if (s.equalsIgnoreCase("false")) {
return false;
} else {
throw new InvalidArgumentException(getName(), "expected true or false");
}
}
}
View on GitHub (pinned to a66e9ccd1d)
Solutions
- Use exactly 'true' or 'false' (any case) as the option value.
- For flags declared to accept a bare '--flag' with the value in the next token, ensure the next token is not accidentally another option.
- Audit environment variables feeding the command for 0/1/on/off values and map them to true/false.
Example fix
# before mx profdiff normal-tier --experiment1 a --experiment2 b --percentages=falsey # after mx profdiff normal-tier --experiment1 a --experiment2 b --percentages=false
Defensive patterns
Strategy: validation
Validate before calling
static boolean isBooleanArg(String s) { return s != null && (s.equalsIgnoreCase("true") || s.equalsIgnoreCase("false")); }
// gate the value before it reaches BooleanArgument.parseValue Type guard
static boolean isParsableBoolean(String s) {
return s != null && (s.equalsIgnoreCase("true") || s.equalsIgnoreCase("false"));
} Try / catch
try {
parser.parse(args);
} catch (InvalidArgumentException e) {
if (e.getMessage().contains("expected true or false")) { /* fix the value */ }
} Prevention
- Use only true/false for boolean options.
- Map CI variables like 0/1/on/off to true/false in wrapper scripts.
When it happens
Trigger: Passing '--someflag=1', '--someflag=yes', or an empty value '--someflag=' to any boolean option of profdiff or of a custom parser built on this args package.
Common situations: Porting shell scripts from tools that accept 0/1 or on/off for booleans; typos like 'ture'; CI variables that expand to 'Yes'.
Related errors
- no value provided
- invalid boolean value: "%s"
- Unknown option '%s'.
- The argument '%s' is required.
- The argument '%s' could not be parsed: invalid command name:
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/bd13bc365539eab5.
Report an issue: GitHub.