theonedev/onedev · error · IllegalArgumentException

Delta length ( ) larger than source text length ( ).

Error message

Delta length (${pointer}) larger than source text length (${text1.length()}).

What it means

After parsing the length n, diff_fromDelta takes text1.substring(pointer, pointer+n); a StringIndexOutOfBoundsException means the delta claims more characters than remain in the source text, so the delta does not match text1.

Solutions

  1. Ensure the delta was generated from the same text1 being passed in.
  2. Regenerate the delta pair instead of reusing a stale one.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at server-core/src/main/java/io/onedev/server/util/diff/DiffMatchPatch.java:1549 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/e818f394aea0067b. Report an issue: GitHub.

Appendix: source

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

				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);
					}
					String text;
					try {
						text = text1.substring(pointer, pointer += n);
					} catch (StringIndexOutOfBoundsException e) {
						throw new IllegalArgumentException("Delta length (" + pointer
								+ ") larger than source text length (" + text1.length() + ").", e);
					}
					if (token.charAt(0) == '=') {
						diffs.add(new Diff(Operation.EQUAL, text));
					} else {
						diffs.add(new Diff(Operation.DELETE, text));
					}
					break;
				default:
					// Anything else is an error.
					throw new IllegalArgumentException("Invalid diff operation in diff_fromDelta: "
							+ token.charAt(0));
			}
		}
		if (pointer != text1.length()) {
			throw new IllegalArgumentException("Delta length (" + pointer
					+ ") smaller than source text length (" + text1.length() + ").");
		}

View on GitHub (pinned to d44925c47c)