{"record":{"id":"59935aa307b821b4","repo":"oracle/graal","slug":"no-value-provided-59935a","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/IntegerValue.java","lineNumber":42,"sourceCode":" */\npackage jdk.graal.compiler.util.args;\n\n/**\n * Parses a {@link Integer} from command line arguments.\n */\npublic class IntegerValue extends OptionValue<Integer> {\n    public IntegerValue(String name, String help) {\n        super(name, help);\n    }\n\n    public IntegerValue(String name, Integer 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        try {\n            value = Integer.valueOf(arg);\n            return true;\n        } catch (NumberFormatException e) {\n            throw new InvalidArgumentException(getName(), String.format(\"invalid double value: \\\"%s\\\"\", arg));\n        }\n    }\n}\n","sourceCodeStart":24,"sourceCodeEnd":52,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/args/IntegerValue.java#L24-L52","documentation":"InvalidArgumentException from IntegerValue.parseValue: the option was declared as an Integer but parseValue received null — the option name was present with no operand. Note a known copy-paste defect in this class: the NumberFormatException branch reuses DoubleValue's message text ('invalid double value') even though Integer.valueOf is what is parsed, so the sibling unparseable-value error for integers is mislabeled.","triggerScenarios":"A Command/OptionValue-based CLI where an int option token appears at the end of args or its value element was dropped, so the framework calls IntegerValue.parseValue(null) and the 'no value provided' branch fires.","commonSituations":"Scripts conditionally appending option names but not values; shell continuations dropping the next line; users assuming a bare '--max-depth' picks a default.","solutions":["Pass an explicit integer: '--max-depth=5' or 'max-depth 5' per the parser's convention.","Declare a default via new IntegerValue(name, defaultValue, help) so omitting the option entirely is valid.","When debugging a follow-up 'invalid double value' error from an int option, remember it actually means Integer.valueOf failed (copy-paste bug) — check the string is a plain int literal."],"exampleFix":"# before\n$ tool --max-depth\n\n# after\n$ tool --max-depth=5","handlingStrategy":"validation","validationCode":"// Ensure every integer option token carries a value before parsing\nfor (int i = 0; i < args.length; i++) {\n    if (isIntOption(args[i]) && !args[i].contains(\"=\") && i + 1 >= args.length) {\n        fail(args[i] + \" requires an integer value, e.g. \" + args[i] + \"=5\");\n    }\n}","typeGuard":"static boolean isParsableInt(String s) {\n    if (s == null) return false;\n    try { Integer.parseInt(s.trim()); return true; } catch (NumberFormatException e) { return false; }\n}","tryCatchPattern":"try {\n    cmd.parse(args);\n} catch (InvalidArgumentException e) {\n    // note: unparseable int values are mislabeled 'invalid double value' in IntegerValue\n    if (\"no value provided\".equals(e.getMessage()) || e.getMessage().contains(\"invalid double value\")) {\n        System.err.println(e.getOption() + \" needs an integer like \" + e.getOption() + \"=5\");\n    } else throw e;\n}","preventionTips":["Use '='-style ('--opt=5') in scripts to keep name and value together.","Provide defaults via the (name, defaultValue, help) constructor so omission is safe.","When you see 'invalid double value' from an int option, blame the copy-paste bug in IntegerValue and check the raw token."],"tags":["cli","arguments","integer","parsing","options","known-bug"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}