{"record":{"id":"f7c406fa0b92d8ec","repo":"apache/maven","slug":"failed-to-parse-arguments-from-maven-config-file","errorCode":null,"errorMessage":"Failed to parse arguments from maven.config file (${configFile}): ${message}","messagePattern":"Failed to parse arguments from maven\\.config file \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenParser.java","lineNumber":91,"sourceCode":"                    \"Failed to parse arguments from file (\" + atFile + \"): \" + e.getMessage(), e.getCause());\n        } catch (IOException e) {\n            throw new IllegalStateException(\"Error reading config file: \" + atFile, e);\n        }\n    }\n\n    protected MavenOptions parseMavenConfigOptions(Path configFile) {\n        try (Stream<String> lines = Files.lines(configFile, StandardCharsets.UTF_8)) {\n            List<String> args =\n                    lines.filter(arg -> !arg.isEmpty() && !arg.startsWith(\"#\")).toList();\n            MavenOptions options = parseArgs(\"maven.config\", args);\n            if (options.goals().isPresent()) {\n                // This file can only contain options, not args (goals or phases)\n                throw new IllegalArgumentException(\"Unrecognized entries in maven.config (\" + configFile + \") file: \"\n                        + options.goals().get());\n            }\n            return options;\n        } catch (ParseException e) {\n            throw new IllegalArgumentException(\n                    \"Failed to parse arguments from maven.config file (\" + configFile + \"): \" + e.getMessage(),\n                    e.getCause());\n        } catch (IOException e) {\n            throw new IllegalStateException(\"Error reading config file: \" + configFile, e);\n        }\n    }\n\n    protected MavenOptions parseArgs(String source, List<String> args) throws ParseException {\n        return CommonsCliMavenOptions.parse(source, args.toArray(new String[0]));\n    }\n}\n","sourceCodeStart":73,"sourceCodeEnd":103,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/mvn/MavenParser.java#L73-L103","documentation":"The contents of .mvn/maven.config (empty and `#` lines dropped, each line one argument) failed Commons CLI parsing in MavenParser.parseMavenConfigOptions. Same failure class as a bad command line, but the offending token lives in the per-project config file that is parsed on every build in that project. The message includes the file path and the ParseException reason.","triggerScenarios":"An option and its value merged on one line (`-T 1C`), an unknown option for the installed Maven version, or an option missing its value inside .mvn/maven.config.","commonSituations":"Upgrading Maven majors and leaving removed flags in maven.config; copying options from blog posts that use shell syntax not valid line-per-argument format; different developers on different Maven versions sharing one config file.","solutions":["Fix the token named by the ParseException text in the message.","Put option and value on separate lines (each line = exactly one argument).","Remove options not supported by the installed Maven version.","Validate edits with a cheap invocation (`mvn -v`) in the project directory."],"exampleFix":"# before: .mvn/maven.config - one line is one argument, '-T 1C' is invalid\n-T 1C\n\n# after\n-T\n1C","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    new MavenParser().parseMavenConfigOptions(configFile);\n} catch (IllegalArgumentException e) {\n    // message names the file and the offending token\n    reportConfigError(configFile, e.getMessage());\n} catch (IllegalStateException e) {\n    reportUnreadable(configFile, e);\n}","preventionTips":["Each line of maven.config is exactly one argument - never merge option and value.","Test config changes with `mvn -v` in the project before pushing."],"tags":["maven","maven-config","argument-parsing"],"backgroundTag":"cli-argument-parsing-failed","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}