{"record":{"id":"bd13bc365539eab5","repo":"oracle/graal","slug":"the-argument-s-could-not-be-parsed-expected-tr","errorCode":null,"errorMessage":"The argument '%s' could not be parsed: expected true or false","messagePattern":"The argument '(.+?)' could not be parsed: expected true or false","errorType":"validation","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/args/BooleanArgument.java","lineNumber":42,"sourceCode":" */\npackage org.graalvm.profdiff.args;\n\n/**\n * A program argument that holds a boolean.\n */\npublic class BooleanArgument extends ValuedArgument<Boolean> {\n    public BooleanArgument(String name, boolean defaultValue, String help) {\n        super(name, defaultValue, help);\n    }\n\n    @Override\n    protected Boolean parseValue(String s) throws InvalidArgumentException {\n        if (s.equalsIgnoreCase(\"true\")) {\n            return true;\n        } else if (s.equalsIgnoreCase(\"false\")) {\n            return false;\n        } else {\n            throw new InvalidArgumentException(getName(), \"expected true or false\");\n        }\n    }\n}\n","sourceCodeStart":24,"sourceCodeEnd":46,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/args/BooleanArgument.java#L24-L46","documentation":"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').","triggerScenarios":"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.","commonSituations":"Porting shell scripts from tools that accept 0/1 or on/off for booleans; typos like 'ture'; CI variables that expand to 'Yes'.","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."],"exampleFix":"# before\nmx profdiff normal-tier --experiment1 a --experiment2 b --percentages=falsey\n# after\nmx profdiff normal-tier --experiment1 a --experiment2 b --percentages=false","handlingStrategy":"validation","validationCode":"static boolean isBooleanArg(String s) { return s != null && (s.equalsIgnoreCase(\"true\") || s.equalsIgnoreCase(\"false\")); }\n// gate the value before it reaches BooleanArgument.parseValue","typeGuard":"static boolean isParsableBoolean(String s) {\n    return s != null && (s.equalsIgnoreCase(\"true\") || s.equalsIgnoreCase(\"false\"));\n}","tryCatchPattern":"try {\n    parser.parse(args);\n} catch (InvalidArgumentException e) {\n    if (e.getMessage().contains(\"expected true or false\")) { /* fix the value */ }\n}","preventionTips":["Use only true/false for boolean options.","Map CI variables like 0/1/on/off to true/false in wrapper scripts."],"tags":["cli","arguments","boolean","profdiff"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}