theonedev/onedev · error · IllegalArgumentException

Delta length (${pointer}) smaller than source text length ($

Error message

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

What it means

Final consistency check of diff_fromDelta: after consuming all tokens, pointer must equal text1.length(); a shorter pointer means the delta accounts for fewer characters than the source text contains, so delta and text are out of sync.

Source

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

						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() + ").");
		}
		return diffs;
	}


	// MATCH FUNCTIONS


	/**
	 * Locate the best instance of 'pattern' in 'text' near 'loc'. Returns -1 if
	 * no match found.
	 * 
	 * @param text The text to search.
	 * @param pattern The pattern to search for.
	 * @param loc The location to search around.
	 * @return Best match index or -1.
	 */

View on GitHub (pinned to d44925c47c)

Solutions

  1. Regenerate the delta from the exact text1 supplied.
  2. Verify no text was truncated or altered between delta creation and parsing.
Defensive patterns

Strategy: validation

When it happens

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