{"record":{"id":"8bee44af4095579b","repo":"quarkusio/quarkus","slug":"incomplete-escape-sequence-at-the-end-of-input-in","errorCode":null,"errorMessage":"Incomplete escape sequence at the end of input in glob %s","messagePattern":"Incomplete escape sequence at the end of input in glob (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/app-model/src/main/java/io/quarkus/util/GlobUtil.java","lineNumber":145,"sourceCode":"                    i--;\n                    i = glob(glob, i, length, \",}\", result);\n                    break;\n            }\n        }\n        throw new IllegalStateException(String.format(\"Missing } at the end of input in glob %s\", glob));\n    }\n\n    private static int unescape(String glob, int i, int length, StringBuilder result, boolean charClass) {\n        if (i < length) {\n            final char current = glob.charAt(i++);\n            if (charClass) {\n                escapeCharClassIfNeeded(current, result);\n            } else {\n                escapeIfNeeded(current, result);\n            }\n            return i;\n        } else {\n            throw new IllegalStateException(\n                    String.format(\"Incomplete escape sequence at the end of input in glob %s\", glob));\n        }\n    }\n\n    private static int charClass(String glob, int i, int length, StringBuilder result) {\n        result.append(\"[[^/]&&[\");\n        if (i < length && glob.charAt(i) == '!') {\n            i++;\n            result.append('^');\n        }\n        while (i < length) {\n            char current = glob.charAt(i++);\n            switch (current) {\n                case ']':\n                    result.append(\"]]\");\n                    return i;\n                case '-':\n                    result.append('-');","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/app-model/src/main/java/io/quarkus/util/GlobUtil.java#L127-L163","documentation":"GlobUtil.unescape() throws IllegalStateException when a backslash is the last character of the glob pattern with nothing following to unescape. An escape sequence requires at least one character after the backslash, so a trailing '\\' is incomplete input.","triggerScenarios":"Passing a glob ending in '\\', e.g. 'path\\to\\' or 'foo\\', to GlobUtil; unescape is reached from glob() or charClass() whenever it consumes a backslash at end of input.","commonSituations":"Windows-style path separators used in patterns instead of '/'; string concatenation or templating that dropped the final escaped character (e.g. 'foo\\*' losing the '*'); shell/config escaping layers eating the trailing char.","solutions":["Remove the trailing backslash or escape it explicitly ('\\\\') if a literal backslash is intended","Use forward slashes in glob patterns ('path/to/**') since globs are not Windows-path aware","Check upstream string building so the character after '\\' is not stripped by another escaping layer"],"exampleFix":"// before\nGlobUtil.toRegexPattern(\"src/main\\\\\");\n// after\nGlobUtil.toRegexPattern(\"src/main/**\");","handlingStrategy":"validation","validationCode":"static boolean endsWithCompleteEscape(String glob) {\n    int backslashes = 0;\n    for (int i = glob.length() - 1; i >= 0 && glob.charAt(i) == '\\\\'; i--) backslashes++;\n    return backslashes % 2 == 0;\n}","typeGuard":null,"tryCatchPattern":"try {\n    return GlobUtil.toRegexPattern(glob);\n} catch (IllegalStateException e) {\n    if (e.getMessage().startsWith(\"Incomplete escape sequence\")) {\n        throw new IllegalArgumentException(\"Trailing backslash in glob: \" + glob, e);\n    }\n    throw e;\n}","preventionTips":["Use forward slashes in glob patterns instead of Windows backslashes","When escaping is needed, ensure the escaped character survives any upstream string escaping (config files, templates, shells)","Reject or repair patterns ending in an odd number of backslashes before use"],"tags":["glob","escaping","parsing"],"backgroundTag":"incomplete-escape-sequence","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}