eclipse-vertx/vert.x · error · IllegalArgumentException

partial escape sequence at end of string: ${s}

Error message

partial escape sequence at end of string: ${s}

What it means

URI decoding failure in decodeAndTransformURIComponent: a percent sign is followed by only one character before the string ends (and it is not a second '%'), leaving an incomplete two-hex-digit escape sequence. The offending string is included in the message.

Source

Thrown at vertx-core/src/main/java/io/vertx/core/internal/net/RFC3986.java:90

  }

  private static String decodeAndTransformURIComponent(String s, int i, boolean plus) {
    final byte[] buf = s.getBytes(StandardCharsets.UTF_8);
    int pos = i;  // position in `buf'.
    for (int size = s.length(); i < size; i++) {
      char c = s.charAt(i);
      if (c == '%') {
        if (i == size - 1) {
          throw new IllegalArgumentException("unterminated escape"
            + " sequence at end of string: " + s);
        }
        c = s.charAt(++i);
        if (c == '%') {
          buf[pos++] = '%';  // "%%" -> "%"
          break;
        }
        if (i >= size - 1) {
          throw new IllegalArgumentException("partial escape"
            + " sequence at end of string: " + s);
        }
        c = decodeHexNibble(c);
        final char c2 = decodeHexNibble(s.charAt(++i));
        if (c == Character.MAX_VALUE || c2 == Character.MAX_VALUE) {
          throw new IllegalArgumentException(
            "invalid escape sequence `%" + s.charAt(i - 1)
              + s.charAt(i) + "' at index " + (i - 2)
              + " of: " + s);
        }
        c = (char) (c * 16 + c2);
        // shouldn't check for plus since it would be a double decoding
        buf[pos++] = (byte) c;
      } else {
        buf[pos++] = (byte) (plus && c == '+' ? ' ' : c);
      }
    }
    return new String(buf, 0, pos, StandardCharsets.UTF_8);

View on GitHub (pinned to fb308bd8c3)

Solutions

  1. Complete or remove the partial escape sequence
  2. Percent-encode stray '%' characters as '%25' before decoding
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at vertx-core/src/main/java/io/vertx/core/internal/net/RFC3986.java:90 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of eclipse-vertx/vert.x@fb308bd8c3 (2026-09-06). Data as JSON: /api/errors/7eb9ae856999677a. Report an issue: GitHub.