{"record":{"id":"2ed43139b85f4482","repo":"oracle/graal","slug":"no-choice-named-s","errorCode":null,"errorMessage":"no choice named '%s'","messagePattern":"no choice named '(.+?)'","errorType":"validation","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/args/MultiChoiceValue.java","lineNumber":58,"sourceCode":"    private String defaultChoice = null;\n\n    public MultiChoiceValue(String name, String help) {\n        super(name, help);\n    }\n\n    public MultiChoiceValue(String name, T 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            value = defaultValue;\n            return false;\n        }\n        value = choices.get(arg);\n        if (value == null) {\n            throw new InvalidArgumentException(getName(), String.format(\"no choice named '%s'\", arg));\n        }\n        return true;\n    }\n\n    /**\n     * Adds a choice to the set of alternatives for this option.\n     *\n     * @param name user-visible name for the alternative, as will be parsed from the command-line.\n     * @param choiceValue value that will be returned if the given choice is selected.\n     * @param help help text for the choice in question.\n     * @return {@code this}\n     */\n    public MultiChoiceValue<T> addChoice(String name, T choiceValue, String help) {\n        choices.put(name, choiceValue);\n        choiceHelp.put(name, help);\n        if (choiceValue.equals(defaultValue)) {\n            defaultChoice = name;\n        }","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/util/args/MultiChoiceValue.java#L40-L76","documentation":"Thrown by MultiChoiceValue.parseValue when the parsed string is not a key in the choices map, i.e. no alternative with that name was registered via addChoice before parsing. It signals a typo or an unregistered alternative for a multi-choice option.","triggerScenarios":"Calling parseValue(arg) on a MultiChoiceValue where arg does not exactly match any name passed to addChoice(...) — including case mismatches, or calling parseValue before any addChoice calls were made. Only a null arg silently resets to the default; every other unknown string throws.","commonSituations":"Misspelling a choice on the command line (-D:SomeOption=inlien instead of inline), using different capitalization than the registered name, or a version change where a choice name was renamed/removed while old scripts still pass it.","solutions":["List the valid choices for the option (check the option's help text or its addChoice calls) and use an exact-match name","Fix spelling/capitalization of the passed value","If the choice genuinely should exist, call addChoice(name, value, help) on the MultiChoiceValue before parsing","Omit the option entirely to fall back to the default value"],"exampleFix":"// before\nMultiChoiceValue<String> mode = new MultiChoiceValue<>(\"Mode\", \"a\", \"help\");\nmode.parseValue(\"fast\");            // InvalidArgumentException: no choice named 'fast'\n\n// after\nMultiChoiceValue<String> mode = new MultiChoiceValue<>(\"Mode\", \"a\", \"help\").addChoice(\"fast\", \"F\", \"fast mode\");\nmode.parseValue(\"fast\");","handlingStrategy":"validation","validationCode":"if (!choiceValue.choices().containsKey(arg)) { // expose or mirror the choices map\n    throw new IllegalArgumentException(\"unknown choice '\" + arg + \"', valid: \" + choiceValue.choices().keySet());\n}","typeGuard":null,"tryCatchPattern":"catch (InvalidArgumentException e) { fall back to defaultValue explicitly: value = defaultValue; }","preventionTips":["Register all choices with addChoice before any parseValue call","Derive accepted values from the option's help/choices, never hardcode them in scripts","Treat choice renames as breaking changes in release notes"],"tags":["graalvm","options","parsing","configuration"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}