quarkusio/quarkus · error · IllegalStateException

Missing ] at the end of input in glob %s

Error message

Missing ] at the end of input in glob %s

What it means

GlobUtil's character-class parser ([abc]) throws IllegalStateException when the input ends inside an unclosed '['. The charClass() loop consumes characters until it finds ']', and hitting end-of-input first means the bracket expression is unterminated.

Source

Thrown at independent-projects/bootstrap/app-model/src/main/java/io/quarkus/util/GlobUtil.java:173

        }
        while (i < length) {
            char current = glob.charAt(i++);
            switch (current) {
                case ']':
                    result.append("]]");
                    return i;
                case '-':
                    result.append('-');
                    break;
                case '\\':
                    i = unescape(glob, i, length, result, true);
                    break;
                default:
                    escapeCharClassIfNeeded(current, result);
                    break;
            }
        }
        throw new IllegalStateException(String.format("Missing ] at the end of input in glob %s", glob));
    }

    private static void escapeIfNeeded(char current, StringBuilder result) {
        switch (current) {
            case '*':
            case '?':
            case '+':
            case '.':
            case '^':
            case '$':
            case '{':
            case '[':
            case ']':
            case '|':
            case '(':
            case ')':
            case '\\':
                result.append('\\');

View on GitHub (pinned to e1c734241f)

Solutions

  1. Add the closing ']': 'file[0-9]' not 'file[0-9'
  2. If '[' is meant literally, escape it as '\['
  3. Validate bracket balance (equal '[' and ']' counts, ignoring escaped ones) before applying the glob

Example fix

// before
GlobUtil.toRegexPattern("file[0-9");
// after
GlobUtil.toRegexPattern("file[0-9]");
Defensive patterns

Strategy: validation

Validate before calling

static boolean bracketsBalanced(String glob) {
    int open = 0;
    for (int i = 0; i < glob.length(); i++) {
        if (glob.charAt(i) == '\\') { i++; continue; }
        if (glob.charAt(i) == '[') open++;
        else if (glob.charAt(i) == ']' && open > 0) open--;
    }
    return open == 0;
}

Try / catch

try {
    return GlobUtil.toRegexPattern(glob);
} catch (IllegalStateException e) {
    if (e.getMessage().startsWith("Missing ]")) {
        throw new IllegalArgumentException("Unclosed '[' in glob: " + glob, e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Passing a glob with '[' but no ']', e.g. 'file[0-9' or 'a[!bc' ; charClass() is entered from glob() whenever '[' is encountered.

Common situations: Malformed include/exclude patterns in Quarkus config where ']' was accidentally deleted; patterns where the intended ']' was escaped or consumed by an earlier parsing bug; writing classes with a hyphen or '!' and forgetting to close them.

Related errors


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