{"record":{"id":"df859c2e42211f36","repo":"oracle/graal","slug":"the-argument-s-could-not-be-parsed-invalid-com","errorCode":null,"errorMessage":"The argument '%s' could not be parsed: invalid command name: %s","messagePattern":"The argument '(.+?)' could not be parsed: invalid command name: (.+?)","errorType":"validation","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/args/CommandGroup.java","lineNumber":107,"sourceCode":"     * Creates a usage string listing the commands of this group and their help strings.\n     *\n     * @return the usage string listing the commands\n     */\n    public String formatCommandsHelp() {\n        Formatter fmt = new Formatter();\n        fmt.format(\"available commands:%n\");\n        for (Command command : commands.getValues()) {\n            fmt.format(\"  %-30s %s%n\", command.getName(), command.getDescription());\n        }\n        return fmt.toString();\n    }\n\n    @Override\n    int parse(String[] args, int offset) throws InvalidArgumentException, UnknownArgumentException, MissingArgumentException {\n        String command = args[offset];\n        selectedCommand = commands.get(args[offset]);\n        if (selectedCommand == null) {\n            throw new InvalidArgumentException(getName(), \"invalid command name: \" + command);\n        }\n        selectedCommand.getArgumentParser().parse(Arrays.copyOfRange(args, offset + 1, args.length));\n        return args.length;\n    }\n}\n","sourceCodeStart":89,"sourceCodeEnd":113,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/org.graalvm.profdiff/src/org/graalvm/profdiff/args/CommandGroup.java#L89-L113","documentation":"Thrown by CommandGroup.parse when the first token of a command group does not match any registered subcommand name in its 'commands' map. CommandGroup is itself an Argument placed as a positional, so an unrecognized subcommand is reported as an invalid value of the group argument. Surfaces as InvalidArgumentException with 'invalid command name: <token>'.","triggerScenarios":"Calling a parser that has a CommandGroup with a token like 'dif' instead of an exact registered command name; case mismatches ('Normal-Tier' vs 'normal-tier'); passing an option where the subcommand name is expected.","commonSituations":"Typos or abbreviations of profdiff subcommands, renamed commands between GraalVM versions, or shell completion inserting the wrong token.","solutions":["Print the group's help: it lists 'available commands:' with exact names; use one verbatim.","Check case and hyphenation of the command token.","If embedding, ensure every subcommand you intend to support was registered on the CommandGroup before parse."],"exampleFix":"# before\nmx profdiff difftiers --experiment1 a --experiment2 b\n# after (exact command name from help)\nmx profdiff normal-tier --experiment1 a --experiment2 b","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Before invoking, check the subcommand token against the group's commands\nboolean known = commandGroup.getCommands().getValues().stream()\n    .anyMatch(c -> c.getName().equals(args[0]));","tryCatchPattern":"try {\n    parser.parse(args);\n} catch (InvalidArgumentException e) {\n    if (e.getMessage().contains(\"invalid command name\")) { /* print available commands */ }\n}","preventionTips":["Use shell completion or copy the command name from help.","Beware case and hyphen differences between versions."],"tags":["cli","arguments","subcommand","profdiff"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}