{"record":{"id":"d3e7d3361ef90a5c","repo":"quarkusio/quarkus","slug":"invalid-command-line-cmdline","errorCode":null,"errorMessage":"Invalid command line: ${cmdLine}","messagePattern":"Invalid command line: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/options/BootstrapMavenOptions.java","lineNumber":61,"sourceCode":"    public static final String OFFLINE = \"o\";\n    public static final String SUPRESS_SNAPSHOT_UPDATES = \"nsu\";\n    public static final String UPDATE_SNAPSHOTS = \"U\";\n    public static final String CHECKSUM_FAILURE_POLICY = \"C\";\n    public static final String CHECKSUM_WARNING_POLICY = \"c\";\n    public static final String BATCH_MODE = \"B\";\n    public static final String NO_TRANSFER_PROGRESS = \"ntp\";\n    public static final String SYSTEM_PROPERTY = \"D\";\n\n    public static Map<String, Object> parse(String cmdLine) {\n        if (cmdLine == null) {\n            return Collections.emptyMap();\n        }\n\n        final String[] args;\n        try {\n            args = CommandLineUtils.translateCommandline(cmdLine);\n        } catch (CommandLineException e) {\n            throw new IllegalArgumentException(\"Invalid command line: \" + cmdLine, e);\n        }\n\n        if (args.length == 0) {\n            return Collections.emptyMap();\n        }\n\n        final String mavenHome = PropertyUtils.getProperty(\"maven.home\");\n        if (mavenHome == null) {\n            try {\n                return invokeParser(Thread.currentThread().getContextClassLoader(), args);\n            } catch (ClassNotFoundException e) {\n                throw new RuntimeException(\"Failed to load parser\", e);\n            }\n        }\n\n        final Path mvnLib = Paths.get(mavenHome).resolve(\"lib\");\n        if (!Files.exists(mvnLib)) {\n            throw new IllegalStateException(\"Maven lib dir does not exist: \" + mvnLib);","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/maven-resolver/src/main/java/io/quarkus/bootstrap/resolver/maven/options/BootstrapMavenOptions.java#L43-L79","documentation":"BootstrapMavenOptions.parse(String cmdLine) first translates the raw command line string into arguments using CommandLineUtils.translateCommandline. If the string has unbalanced quotes or otherwise cannot be tokenized (CommandLineException), it throws IllegalArgumentException with the offending command line in the message.","triggerScenarios":"Calling BootstrapMavenOptions.newInstance(cmdLine) or parse() with a command line string containing unterminated quotes, e.g. -Dkey=\"value (missing closing quote) or mismatched single/double quotes.","commonSituations":"Programmatically building MAVEN_OPTS/maven command strings by string concatenation and dropping a quote, copying command lines from shell snippets where quoting semantics differ, env vars (MAVEN_OPTS) with nested quotes set incorrectly.","solutions":["Print the cmdLine from the message and fix unbalanced or mismatched quotes before passing it","Build the argument list programmatically and join carefully, or avoid embedding quoted -D values (Maven accepts -Dkey=value without quotes when passed as a single arg)","Pre-test the string with org.codehaus.plexus.util.cli.CommandLineUtils.translateCommandline in a unit test","Sanitize environment-provided values (MAVEN_OPTS) by trimming or re-quoting them before concatenation"],"exampleFix":"// before\nBootstrapMavenOptions.newInstance(\"-Dmaven.repo.local=\\\"${HOME}/.m2\"); // unterminated quote\n// after\nBootstrapMavenOptions.newInstance(\"-Dmaven.repo.local=\" + repoDir.getAbsolutePath());","handlingStrategy":"validation","validationCode":"// Check quotes are balanced before handing the string to the parser\nlong dq = cmdLine.chars().filter(c -> c == '\"').count();\nlong sq = cmdLine.chars().filter(c -> c == '\\'').count();\nif (dq % 2 != 0 || sq % 2 != 0) {\n    throw new IllegalArgumentException(\"Unbalanced quotes in command line: \" + cmdLine);\n}","typeGuard":null,"tryCatchPattern":"try {\n    BootstrapMavenOptions options = BootstrapMavenOptions.newInstance(cmdLine);\n} catch (IllegalArgumentException e) {\n    log.error(\"Cannot tokenize command line, fix quoting: \" + e.getMessage());\n    throw e;\n}","preventionTips":["Build command lines from arrays/lists of arguments instead of string concatenation","Avoid quoting -D values unnecessarily; pass key=value as one token","Sanitize environment-provided values before embedding them in command strings","Unit-test the exact command string with CommandLineUtils.translateCommandline"],"tags":["command-line","parsing","maven","illegal-argument"],"backgroundTag":"invalid-command-line","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}