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

  1. Remove the trailing backslash or escape it explicitly ('\\') if a literal backslash is intended
  2. Use forward slashes in glob patterns ('path/to/**') since globs are not Windows-path aware
  3. 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

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


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/8bee44af4095579b. Report an issue: GitHub.