{"record":{"id":"daceaf435b41598e","repo":"apache/maven","slug":"failed-to-parse-command-line-options-daceaf","errorCode":null,"errorMessage":"Failed to parse command line options: {}","messagePattern":"Failed to parse command line options: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/UpgradeParser.java","lineNumber":31,"sourceCode":" * software distributed under the License is distributed on an\n * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n * KIND, either express or implied.  See the License for the\n * specific language governing permissions and limitations\n * under the License.\n */\npackage org.apache.maven.cling.invoker.mvnup;\n\nimport org.apache.commons.cli.ParseException;\nimport org.apache.maven.api.cli.Options;\nimport org.apache.maven.cling.invoker.BaseParser;\n\npublic class UpgradeParser extends BaseParser {\n    @Override\n    protected Options parseCliOptions(LocalContext context) {\n        try {\n            return CommonsCliUpgradeOptions.parse(context.parserRequest.args().toArray(new String[0]));\n        } catch (ParseException e) {\n            throw new IllegalArgumentException(\"Failed to parse command line options: \" + e.getMessage(), e);\n        }\n    }\n}\n","sourceCodeStart":13,"sourceCodeEnd":35,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvnup/UpgradeParser.java#L13-L35","documentation":"The Maven upgrade helper (mvnup) parses its own command line with CommonsCliUpgradeOptions; a ParseException is rethrown as IllegalArgumentException 'Failed to parse command line options' with the reason. Only the upgrade tool's options are in scope, not general mvn build options.","triggerScenarios":"Passing an option the upgrade tool does not define, a misspelled long option, or a value-taking option without its value; flags valid only in a different Maven version's tool.","commonSituations":"Trying the new upgrade tool with habitual mvn flags; CI wrappers appending global options to all tool invocations; docs from a different tool version.","solutions":["Run the tool's help output and use only the listed options.","Correct or drop the flag named in the ParseException text.","Ensure each value-taking option has its value on the command line."],"exampleFix":"# before: unknown option\nmvn up --dry-run-apply\n\n# after: use the tool's actual option spelling (check `mvn up --help`)\nmvn up --help","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    new UpgradeParser().parseCliOptions(context);\n} catch (IllegalArgumentException e) {\n    showUpgradeUsageAndExit(e.getMessage());\n}","preventionTips":["Check `mvn up --help` for the installed version before scripting the upgrade tool.","Do not assume mvn build flags apply to sub-tools."],"tags":["maven","mvnup","upgrade","cli","argument-parsing"],"backgroundTag":"cli-argument-parsing-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}