theonedev/onedev · error · IllegalArgumentException

Illegal escape in diff_fromDelta: ${param}

Error message

Illegal escape in diff_fromDelta: ${param}

What it means

In diff_fromDelta, each token's parameter is URL-decoded; a malformed percent-escape sequence causes IllegalArgumentException, rethrown as 'Illegal escape in diff_fromDelta' naming the bad parameter. Indicates a corrupted delta string.

Source

Thrown at server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java:1526

				// Blank tokens are ok (from a trailing \t).
				continue;
			}
			// Each token begins with a one character parameter which specifies
			// the
			// operation of this token (delete, insert, equality).
			String param = token.substring(1);
			switch (token.charAt(0)) {
				case '+':
					// decode would change all "+" to " "
					param = param.replace("+", "%2B");
					try {
						param = URLDecoder.decode(param, "UTF-8");
					} catch (UnsupportedEncodingException e) {
						// Not likely on modern system.
						throw new Error("This system does not support UTF-8.", e);
					} catch (IllegalArgumentException e) {
						// Malformed URI sequence.
						throw new IllegalArgumentException("Illegal escape in diff_fromDelta: "
								+ param, e);
					}
					diffs.add(new Diff(Operation.INSERT, param));
					break;
				case '-':
					// Fall through.
				case '=':
					int n;
					try {
						n = Integer.parseInt(param);
					} catch (NumberFormatException e) {
						throw new IllegalArgumentException("Invalid number in diff_fromDelta: "
								+ param, e);
					}
					if (n < 0) {
						throw new IllegalArgumentException("Negative number in diff_fromDelta: "
								+ param);
					}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Regenerate the delta via diff_toDelta instead of hand-editing it.
  2. Ensure '+' characters are encoded as %2B in the delta text.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java:1526 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/2c1875585497ce62. Report an issue: GitHub.