{"record":{"id":"31ff003fcb98598a","repo":"oracle/graal","slug":"no-value-provided","errorCode":null,"errorMessage":"no value provided","messagePattern":"no value provided","errorType":"validation","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"warning","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/args/BooleanValue.java","lineNumber":45,"sourceCode":"import java.util.Locale;\n\n/**\n * Parses a literal boolean (\"true\" or \"false\", ignoring case) from command line arguments.\n */\npublic class BooleanValue extends OptionValue<Boolean> {\n\n    public BooleanValue(String name, String help) {\n        super(name, help);\n    }\n\n    public BooleanValue(String name, boolean defaultValue, String help) {\n        super(name, defaultValue, help);\n    }\n\n    @Override\n    public boolean parseValue(String arg) throws InvalidArgumentException {\n        if (arg == null) {\n            throw new InvalidArgumentException(getName(), \"no value provided\");\n        }\n        switch (arg.toLowerCase(Locale.US)) {\n            case \"true\":\n                value = true;\n                break;\n            case \"false\":\n                value = false;\n                break;\n            default:\n                throw new InvalidArgumentException(getName(), String.format(\"invalid boolean value: \\\"%s\\\"\", arg));\n        }\n        return true;\n    }\n}\n","sourceCodeStart":27,"sourceCodeEnd":60,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/args/BooleanValue.java#L27-L60","documentation":"InvalidArgumentException from BooleanValue.parseValue: parseValue was called with a null argument, meaning a boolean command-line option was declared/required but no value string was supplied at parse time. The option framework distinguishes 'missing value' (null) from 'unparseable value' (the sibling 'invalid boolean value' error).","triggerScenarios":"A Command/OptionValue-based CLI parses args where a boolean option name appears at the end of the argument list (or its '=' form has no right-hand side), so the framework passes null into BooleanValue.parseValue.","commonSituations":"Users writing './tool -verbose' (flag style) when the parser expects '-verbose=true'; trailing option name after a shell line-continuation mistake; programmatic arg-array construction that drops the value element.","solutions":["Supply an explicit value: '-optionName=true' or 'optionName true' depending on the parser's convention.","If the option should be a pure flag, use an option type that treats bare presence as true (a Variant/flag style) instead of BooleanValue.","Catch InvalidArgumentException at the CLI boundary and print the option's help text (getName() identifies which option failed)."],"exampleFix":"# before\n$ tool --verbose        # BooleanValue gets null\n\n# after\n$ tool --verbose=true","handlingStrategy":"validation","validationCode":"// Normalize CLI tokens before handing them to the parser\nstatic String ensureBoolValue(String name, String raw) {\n    return (raw == null) ? \"true\" : raw;   // or reject explicitly:\n    // if (raw == null) throw new InvalidArgumentException(name, \"expects =true|=false\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    cmd.parse(args);\n} catch (InvalidArgumentException e) {\n    if (\"no value provided\".equals(e.getMessage())) {\n        printUsage(e.getOption()); // tell user to pass =true/=false\n    } else throw e;\n}","preventionTips":["Always write boolean options in '=true'/'=false' form in scripts.","Give BooleanValue a default at construction so omission is legal.","Print option help text whenever InvalidArgumentException reaches the CLI boundary."],"tags":["cli","arguments","boolean","parsing","options"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}