quarkusio/quarkus · error · IllegalStateException
Incomplete escape sequence at the end of input in glob %s
Error message
Incomplete escape sequence at the end of input in glob %s
What it means
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.
Source
Thrown at independent-projects/bootstrap/app-model/src/main/java/io/quarkus/util/GlobUtil.java:145
i--;
i = glob(glob, i, length, ",}", result);
break;
}
}
throw new IllegalStateException(String.format("Missing } at the end of input in glob %s", glob));
}
private static int unescape(String glob, int i, int length, StringBuilder result, boolean charClass) {
if (i < length) {
final char current = glob.charAt(i++);
if (charClass) {
escapeCharClassIfNeeded(current, result);
} else {
escapeIfNeeded(current, result);
}
return i;
} else {
throw new IllegalStateException(
String.format("Incomplete escape sequence at the end of input in glob %s", glob));
}
}
private static int charClass(String glob, int i, int length, StringBuilder result) {
result.append("[[^/]&&[");
if (i < length && glob.charAt(i) == '!') {
i++;
result.append('^');
}
while (i < length) {
char current = glob.charAt(i++);
switch (current) {
case ']':
result.append("]]");
return i;
case '-':
result.append('-');View on GitHub (pinned to e1c734241f)
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
Example fix
// before
GlobUtil.toRegexPattern("src/main\\");
// after
GlobUtil.toRegexPattern("src/main/**"); Defensive patterns
Strategy: validation
Validate before calling
static boolean endsWithCompleteEscape(String glob) {
int backslashes = 0;
for (int i = glob.length() - 1; i >= 0 && glob.charAt(i) == '\\'; i--) backslashes++;
return backslashes % 2 == 0;
} Try / catch
try {
return GlobUtil.toRegexPattern(glob);
} catch (IllegalStateException e) {
if (e.getMessage().startsWith("Incomplete escape sequence")) {
throw new IllegalArgumentException("Trailing backslash in glob: " + glob, e);
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Missing } at the end of input in glob %s
- Missing ] at the end of input in glob %s
- Control characters not allowed in json string
- Unexpected end of input: ${str}
- Unexpected character '${str.charAt(pos)}' at position ${pos}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/8bee44af4095579b.
Report an issue: GitHub.