{"record":{"id":"72f4d048156fc68e","repo":"oracle/graal","slug":"no-subcommand-named-s","errorCode":null,"errorMessage":"no subcommand named '%s'","messagePattern":"no subcommand named '(.+?)'","errorType":"validation","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"warning","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/args/CommandGroup.java","lineNumber":66,"sourceCode":"     *\n     * @param name the name of the command group\n     * @param defaultCommand the command selected by default\n     * @param help the help message\n     */\n    public CommandGroup(String name, C defaultCommand, String help) {\n        super(name, defaultCommand, help);\n    }\n\n    /**\n     * Parses and updates the selected subcommand based on {@code args[offset]}.\n     *\n     * @see Command#parse(String[], int)\n     */\n    public int parse(String[] args, int offset) throws InvalidArgumentException, HelpRequestedException, CommandParsingException {\n        String arg = args[offset];\n        value = subCommands.get(arg);\n        if (value == null) {\n            throw new InvalidArgumentException(getName(), String.format(\"no subcommand named '%s'\", arg));\n        }\n        return value.parse(args, offset + 1);\n    }\n\n    @Override\n    public final boolean parseValue(String arg) throws InvalidArgumentException {\n        throw GraalError.unimplementedOverride();\n    }\n\n    /**\n     * Adds a command to the set of subcommands.\n     */\n    public C addCommand(C command) {\n        subCommands.put(command.getName(), command);\n        return command;\n    }\n\n    /**","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/args/CommandGroup.java#L48-L84","documentation":"InvalidArgumentException (via CommandParsingException path) from CommandGroup.parse: args[offset] does not match any subcommand name registered with addCommand. CommandGroup models a node in a command hierarchy (e.g. 'mx foo <subcommand> ...'); when the token selects no registered subcommand, parsing stops with 'no subcommand named <arg>' naming the offending token.","triggerScenarios":"Invoking a CLI built on CommandGroup with a misspelled or unregistered subcommand: value = subCommands.get(arg) returns null and the error is thrown before recursion into value.parse continues.","commonSituations":"Typos ('verison' for 'version'); subcommands available only in a different build/distribution; a subcommand renamed or removed in a newer version of the tool; extra global flags placed before the subcommand token so a flag name lands at args[offset].","solutions":["Run the tool with its help flag to list registered subcommands and correct the spelling/order.","Ensure global options come after (or in the position the parser expects) the subcommand token so the subcommand slot holds a real subcommand.","If extending the tool, register your subcommand via addCommand with the exact name (case-sensitive map lookup).","On upgrade, check the changelog for renamed subcommands."],"exampleFix":"# before\n$ mx graal comppile ...   # typo\n\n# after\n$ mx graal compile ...      # registered subcommand","handlingStrategy":"validation","validationCode":"// If you embed CommandGroup, pre-check tokens before parse\nSet<String> known = subCommandNames; // maintained next to addCommand calls\nif (offset < args.length && !known.contains(args[offset])) {\n    printUsage(known);\n    throw new InvalidArgumentException(getName(), \"unknown subcommand '\" + args[offset] + \"'\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    group.parse(args, 0);\n} catch (CommandParsingException | InvalidArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"no subcommand named\")) {\n        printHelpAndListSubcommands(group);\n    } else throw e;\n}","preventionTips":["Always print the registered subcommand list on parse failure.","Keep subcommand names in one constants file so docs, completion scripts, and code cannot drift.","Check the tool's release notes for renamed subcommands before upgrading scripts."],"tags":["cli","arguments","subcommands","parsing","options"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}