theonedev/onedev · error · IllegalArgumentException

Flag {0} not from this walk

Error message

Flag {0} not from this walk

What it means

RevWalk flags are bound to the RevWalk instance that created them (flag.walker). Calling carry(flag) with a flag created by a different RevWalk throws this IllegalArgumentException, since the mask may collide with flags of this walk.

Source

Thrown at server-core/src/main/java/org/eclipse/jgit/revwalk/RevWalk.java:1449

		freeFlags &= ~m;
		return m;
	}

	/**
	 * Automatically carry a flag from a child commit to its parents.
	 * <p>
	 * A carried flag is copied from the child commit onto its parents when the
	 * child commit is popped from the lowest level of walk's internal graph.
	 *
	 * @param flag
	 *            the flag to carry onto parents, if set on a descendant.
	 */
	public void carry(RevFlag flag) {
		if ((freeFlags & flag.mask) != 0)
			throw new IllegalArgumentException(MessageFormat
					.format(JGitText.get().flagIsDisposed, flag.name));
		if (flag.walker != this)
			throw new IllegalArgumentException(MessageFormat
					.format(JGitText.get().flagNotFromThis, flag.name));
		carryFlags |= flag.mask;
	}

	/**
	 * Automatically carry flags from a child commit to its parents.
	 * <p>
	 * A carried flag is copied from the child commit onto its parents when the
	 * child commit is popped from the lowest level of walk's internal graph.
	 *
	 * @param set
	 *            the flags to carry onto parents, if set on a descendant.
	 */
	public void carry(Collection<RevFlag> set) {
		for (RevFlag flag : set)
			carry(flag);
	}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Create the flag from the same walk instance: thisWalk.newFlag(name).
  2. Store flag names, not RevFlag objects, in caches; call newFlag per walk.
  3. Restructure so flags and walks have the same lifecycle.

Example fix

// before
private static final RevFlag SEEN = ...walk.newFlag("SEEN");
otherWalk.carry(SEEN); // throws
// after
RevFlag seen = otherWalk.newFlag("SEEN");
otherWalk.carry(seen);
Defensive patterns

Strategy: type-guard

Validate before calling

if (flag.walker != thisWalk)
    flag = thisWalk.newFlag(flag.getName());
thisWalk.carry(flag);

Type guard

RevFlag rebind(RevWalk w, RevFlag f) { return f.walker == w ? f : w.newFlag(f.getName()); }

Try / catch

try {
    walk.carry(flag);
} catch (IllegalArgumentException e) {
    flag = walk.newFlag(flag.getName()); // recreate for this walk
    walk.carry(flag);
}

Prevention

When it happens

Trigger: Passing a RevFlag from one RevWalk instance to carry() of another; creating a new RevWalk (e.g. per request) but reusing cached RevFlag constants from an old walk; two walks opened on the same repository and flags crossed between them.

Common situations: Framework code caching static RevFlag fields while constructing a new RevWalk each request; tests sharing flags across walks.

Understand the failure class

Background: "unknown output mode", "invalid value for flag", "expects true/false": fixing invalid flag value errors in CLI tools — this error's family across 24 libraries.

Related errors


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