quarkusio/quarkus · error · RuntimeException

Mismatched braces:

Error message

Mismatched braces: 

What it means

The exchange-attribute parser (used for access-log patterns etc.) found an unterminated %{...} group: the token state machine ended in state 2 or 4, meaning an opening brace was never closed, so it throws RuntimeException("Mismatched braces: " + valueString).

Source

Thrown at extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/attribute/ExchangeAttributeParser.java:142

                    state = 0;
                    break;
                }

            }
        }
        switch (state) {
            case 0:
            case 1:
            case 3:
            case 5: {
                if (pos != valueString.length()) {
                    attributes.add(wrap(parseSingleToken(valueString.substring(pos))));
                }
                break;
            }
            case 2:
            case 4: {
                throw new RuntimeException("Mismatched braces: " + valueString);
            }
        }
        if (attributes.size() == 1) {
            return attributes.get(0);
        }
        return new CompositeExchangeAttribute(attributes.toArray(new ExchangeAttribute[attributes.size()]));
    }

    public ExchangeAttribute parseSingleToken(final String token) {
        for (final ExchangeAttributeBuilder builder : builders) {
            ExchangeAttribute res = builder.build(token);
            if (res != null) {
                return res;
            }
        }
        if (token.startsWith("%")) {
            log.errorf("Unknown token %s", token);
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Fix the pattern so every %{ has a matching }: e.g. %{i,Referer}i, %{q}s.
  2. Validate the pattern by starting the app in dev mode — the parser fails fast at startup.
  3. Use documented simple tokens (%h, %r, %b, %{i,Header}i) instead of hand-crafted brace groups.
  4. If quoting issues in application.properties are stripping braces, quote the whole value or escape appropriately.

Example fix

// before (application.properties)
quarkus.http.access-log.pattern=%{Referer
// after
quarkus.http.access-log.pattern=%{i,Referer}i
Defensive patterns

Strategy: validation

Validate before calling

static void validatePattern(String p) {
    int depth = 0;
    for (char c : p.toCharArray()) {
        if (c == '%') continue;
        if (c == '{') depth++;
        if (c == '}') depth--;
        if (depth < 0 || depth > 1) throw new IllegalArgumentException("bad pattern: " + p);
    }
    if (depth != 0) throw new IllegalArgumentException("Mismatched braces in: " + p);
}

Prevention

When it happens

Trigger: Configuring quarkus.http.access-log.pattern (or similar attribute string) with '%{' without the matching '}' — e.g. '%{Referer' instead of '%{i,Referer}'.

Common situations: Hand-edited access log patterns; patterns copied from Undertow docs with partial escapes; properties files where a closing brace was accidentally dropped or swallowed by tooling.

Related errors


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