theonedev/onedev · error · ExplicitException

No commit in query context

Error message

No commit in query context

What it means

FixedInCurrentCommitCriteria.matches() throws this ExplicitException when the in-memory matching path is used for the '~Fixed in current commit' rule without a commit in the query context. Like getPredicate(), it depends on ProjectScopedCommit.get() to know which commit to delegate to; with a null context it cannot decide whether the issue is fixed in the commit.

Source

Thrown at server-core/src/main/java/io/onedev/server/search/entity/issue/FixedInCurrentCommitCriteria.java:32

public class FixedInCurrentCommitCriteria extends Criteria<Issue> {

	private static final long serialVersionUID = 1L;
	
	@Override
	public Predicate getPredicate(@Nullable ProjectScope projectScope, CriteriaQuery<?> query, From<Issue, Issue> from, CriteriaBuilder builder) {
		if (ProjectScopedCommit.get() != null)
			return new FixedInCommitCriteria(ProjectScopedCommit.get()).getPredicate(projectScope, query, from, builder);
		else
			throw new ExplicitException("No commit id in query context");
	}

	@Override
	public boolean matches(Issue issue) {
		if (ProjectScopedCommit.get() != null)
			return new FixedInCommitCriteria(ProjectScopedCommit.get()).matches(issue);
		else
			throw new ExplicitException("No commit in query context");
	}

	@Override
	public String toStringWithoutParens() {
		return IssueQuery.getRuleName(IssueQueryLexer.FixedInCurrentCommit);
	}

}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Run the matching only within a commit context, or set ProjectScopedCommit before calling matches().
  2. Replace the current-commit rule with an explicit '~Fixed in commit(<hash>)' criterion in saved queries.
  3. Filter queries containing context-relative rules out before in-memory evaluation, or pre-validate with ProjectScopedCommit.get() != null.
  4. Catch ExplicitException and fall back to a fixed context or skip the criterion with a warning.

Example fix

// before
criteria.matches(issue); // ProjectScopedCommit.get() == null
// after
if (ProjectScopedCommit.get() != null) {
    criteria.matches(issue);
} else {
    throw new ExplicitException("Evaluate this query within a commit context");
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (ProjectScopedCommit.get() == null) {
    return; // skip in-memory evaluation; no commit context
}

Type guard

boolean canEvaluateFixedInCurrentCommit() {
    return ProjectScopedCommit.get() != null;
}

Try / catch

try {
    boolean hit = criteria.matches(issue);
} catch (ExplicitException e) {
    if (e.getMessage().contains("No commit in query context")) {
        // handle missing commit context (skip, log, or re-run with context)
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling matches(issue) on a query or criterion containing FixedInCurrentCommit when ProjectScopedCommit.get() is null.

Common situations: In-memory issue filtering (e.g. client-side or service-side matches() evaluation) outside of a commit page or commit-triggered job; running saved queries in webhooks or scripts lacking commit context.

Related errors


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