quarkusio/quarkus · error · IllegalStateException
unbalanced quotes in
Error message
unbalanced quotes in
What it means
CommandLineUtil.translateCommandline splits a command-line string into tokens, handling single and double quotes. If the string ends while still inside a quoted section (parser state remains inQuote or inDoubleQuote), it throws IllegalStateException("unbalanced quotes in " + toProcess), because the command line cannot be split unambiguously.
Source
Thrown at core/deployment/src/main/java/io/quarkus/deployment/util/CommandLineUtil.java:102
} else if (" ".equals(nextTok)) {
if (current.length() != 0) {
tokens.add(current.toString());
current.setLength(0);
}
} else {
current.append(nextTok);
inEscape = "\\".equals(nextTok);
}
break;
}
}
if (current.length() != 0) {
tokens.add(current.toString());
}
if ((state == inQuote) || (state == inDoubleQuote)) {
throw new IllegalStateException("unbalanced quotes in " + toProcess);
}
return tokens.toArray(new String[tokens.size()]);
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Inspect the string in the exception and close or remove the unmatched quote
- Prefer passing arguments as a list instead of one quoted string where the config option allows it
- Escape embedded apostrophes/double quotes consistently (e.g. wrap in double quotes and escape \")
- Remove smart quotes (‘ ’ “ ”) that some editors insert — they are not recognized as quote delimiters
Example fix
// before String args = "-Dquarkus.native.additional-build-args=-J-Xmx4g,--verbose 'partial"; // after String args = "-J-Xmx4g,--verbose"; // quote fully closed, or use list form
Defensive patterns
Strategy: validation
Validate before calling
static void validateBalancedQuotes(String cmd) {
boolean inSingle = false, inDouble = false;
for (char c : cmd.toCharArray()) {
if (c == '\'' && !inDouble) inSingle = !inSingle;
else if (c == '"' && !inSingle) inDouble = !inDouble;
}
if (inSingle || inDouble) throw new IllegalArgumentException("Unbalanced quotes in: " + cmd);
}
Try / catch
try {
String[] argv = CommandLineUtil.translateCommandline(cmd);
} catch (IllegalStateException e) {
throw new IllegalArgumentException("Fix quoting in build args: " + e.getMessage(), e);
}
Prevention
- Pass arguments as lists/arrays instead of a single quoted string when the config allows it
- Beware apostrophes inside values (don't, it's) — they open a quote
- Avoid smart quotes pasted from editors; use straight ASCII quotes
When it happens
Trigger: Calling CommandLineUtil.translateCommandline with a string containing an opening single or double quote that is never closed, e.g. 'docker run -e "FOO=bar bash' — an apostrophe inside a value (don't) also opens an unmatched single quote.
Common situations: quarkus.native.additional-build-args style config where users quote args manually; shell commands copied with a missing trailing quote; Windows paths or values containing apostrophes.
Related errors
- Invalid command line: ${cmdLine}
- Failed to parse Maven command line arguments
- Unexpected end of input: ${str}
- Unexpected character '${str.charAt(pos)}' at position ${pos}
- invalid config ${comment}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/c777bd781cfb8122.
Report an issue: GitHub.