{"record":{"id":"fb1dc0518f890f66","repo":"oracle/graal","slug":"unknown-option-s","errorCode":null,"errorMessage":"Unknown option '%s'.","messagePattern":"Unknown option '(.+?)'\\.","errorType":"validation","errorClass":"UnknownArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/args/ArgumentParser.java","lineNumber":82,"sourceCode":"     *\n     * @param args the list of program arguments\n     * @throws InvalidArgumentException the provided argument has an invalid value\n     * @throws MissingArgumentException a required argument is missing in the program arguments\n     * @throws UnknownArgumentException a value was provided for an unknown argument\n     */\n    public void parse(String[] args) throws InvalidArgumentException,\n                    MissingArgumentException,\n                    UnknownArgumentException {\n        int nextPositionalArg = 0;\n        for (int index = 0; index < args.length;) {\n            String arg = args[index];\n            Argument argument;\n            if (arg.startsWith(Argument.OPTION_PREFIX)) {\n                int equalSignIndex = arg.indexOf(Argument.EQUAL_SIGN);\n                String optionArgumentName = equalSignIndex == -1 ? arg : arg.substring(0, equalSignIndex);\n                argument = optionArguments.get(optionArgumentName);\n                if (argument == null) {\n                    throw new UnknownArgumentException(arg);\n                }\n            } else {\n                if (nextPositionalArg >= positionalArguments.size()) {\n                    throw new UnknownArgumentException(arg);\n                }\n                argument = positionalArguments.get(nextPositionalArg++);\n            }\n            index = argument.parse(args, index);\n        }\n        for (Argument argument : optionArguments.getValues()) {\n            if (!argument.isSet() && argument.isRequired()) {\n                throw new MissingArgumentException(argument.getName());\n            }\n        }\n        if (nextPositionalArg < positionalArguments.size() && positionalArguments.get(nextPositionalArg).isRequired()) {\n            throw new MissingArgumentException(positionalArguments.get(nextPositionalArg).getName());\n        }\n    }","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/args/ArgumentParser.java#L64-L100","documentation":"Thrown by ArgumentParser.parse when a command-line token starting with '--' does not match any option argument registered for the current command. The whole token up to the first '=' is used as the lookup key, so both a misspelled flag and a completely unknown flag trigger it. It surfaces as UnknownArgumentException from profdiff's argument-parsing layer.","triggerScenarios":"Calling ArgumentParser.parse(String[]) (directly, or via the profdiff CLI entry) with a token like '--verbsoe' or '--foo=bar' where 'optionArguments.get(\"--foo\")' returns null. Also triggered by options that belong to a different subcommand than the one being invoked.","commonSituations":"Typos in profdiff options (e.g. '--out-format' vs the real '--out' spelling), copying a flag from an older/newer profdiff version where it was renamed, using a subcommand-specific option before/without selecting that subcommand, or passing JVM flags to the profdiff argument parser instead of to the VM.","solutions":["Re-run with the command's help output to list valid options and copy the exact spelling.","Check whether the option belongs to the subcommand you invoked; move it after the subcommand name.","If embedding ArgumentParser, register the option before parse() via the addArgument/addOption helpers so optionArguments contains the name.","If the flag worked before, diff your profdiff/GraalVM version's option list — the name may have changed."],"exampleFix":"# before\nmx profdiff --experiment1 out1 --experiment2 out2 --percentages=50\n# after (use the real option names shown by 'mx profdiff --help')\nmx profdiff --experiment1 out1 --experiment2 out2 --percentage 50","handlingStrategy":"try-catch","validationCode":"// Before calling parser.parse(args), check every '--' token against known options\nSet<String> known = parser.getOptionArguments().keySet().stream().collect(java.util.stream.Collectors.toSet());\nfor (String a : args) {\n    if (a.startsWith(\"--\")) {\n        String key = a.contains(\"=\") ? a.substring(0, a.indexOf('=')) : a;\n        if (!known.contains(key)) throw new IllegalArgumentException(\"Bad option: \" + key);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    parser.parse(args);\n} catch (UnknownArgumentException e) {\n    System.err.println(e.getMessage());\n    System.err.println(parser.getUsage()); // show valid options\n    System.exit(1);\n}","preventionTips":["Derive CLI invocations from the tool's help output, not memory.","Pin the GraalVM/profdiff version in CI so option sets do not drift.","Keep subcommand-specific options after the subcommand token."],"tags":["cli","arguments","profdiff","usage-error"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}