{"record":{"id":"c777bd781cfb8122","repo":"quarkusio/quarkus","slug":"unbalanced-quotes-in","errorCode":null,"errorMessage":"unbalanced quotes in ","messagePattern":"unbalanced quotes in ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"core/deployment/src/main/java/io/quarkus/deployment/util/CommandLineUtil.java","lineNumber":102,"sourceCode":"                    } else if (\" \".equals(nextTok)) {\n                        if (current.length() != 0) {\n                            tokens.add(current.toString());\n                            current.setLength(0);\n                        }\n                    } else {\n                        current.append(nextTok);\n                        inEscape = \"\\\\\".equals(nextTok);\n                    }\n                    break;\n            }\n        }\n\n        if (current.length() != 0) {\n            tokens.add(current.toString());\n        }\n\n        if ((state == inQuote) || (state == inDoubleQuote)) {\n            throw new IllegalStateException(\"unbalanced quotes in \" + toProcess);\n        }\n\n        return tokens.toArray(new String[tokens.size()]);\n    }\n}\n","sourceCodeStart":84,"sourceCodeEnd":108,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/core/deployment/src/main/java/io/quarkus/deployment/util/CommandLineUtil.java#L84-L108","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nString args = \"-Dquarkus.native.additional-build-args=-J-Xmx4g,--verbose 'partial\";\n// after\nString args = \"-J-Xmx4g,--verbose\"; // quote fully closed, or use list form","handlingStrategy":"validation","validationCode":"static void validateBalancedQuotes(String cmd) {\n    boolean inSingle = false, inDouble = false;\n    for (char c : cmd.toCharArray()) {\n        if (c == '\\'' && !inDouble) inSingle = !inSingle;\n        else if (c == '\"' && !inSingle) inDouble = !inDouble;\n    }\n    if (inSingle || inDouble) throw new IllegalArgumentException(\"Unbalanced quotes in: \" + cmd);\n}\n","typeGuard":null,"tryCatchPattern":"try {\n    String[] argv = CommandLineUtil.translateCommandline(cmd);\n} catch (IllegalStateException e) {\n    throw new IllegalArgumentException(\"Fix quoting in build args: \" + e.getMessage(), e);\n}\n","preventionTips":["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"],"tags":["command-line","parsing","quoting"],"backgroundTag":"unbalanced-quotes","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"}