theonedev/onedev · error · ExplicitException
No commit id in query context
Error message
No commit id in query context
What it means
FixedInCurrentCommitCriteria.getPredicate() throws this ExplicitException when the query uses the '~Fixed in current commit' rule but no commit is bound to the query context. It delegates to FixedInCommitCriteria using ProjectScopedCommit.get(); when that context holder is null, the query cannot be translated to a database predicate and the error is thrown.
Source
Thrown at server-core/src/main/java/io/onedev/server/search/entity/issue/FixedInCurrentCommitCriteria.java:24
import javax.persistence.criteria.From;
import javax.persistence.criteria.Predicate;
import io.onedev.commons.utils.ExplicitException;
import io.onedev.server.model.Issue;
import io.onedev.server.util.ProjectScope;
import io.onedev.server.util.ProjectScopedCommit;
import io.onedev.server.util.criteria.Criteria;
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
- Evaluate this query only where a current commit exists (commit detail page, commit-scoped issue views).
- Rewrite the query to use '~Fixed in commit(<hash>)' or a build/branch-based criterion instead of the current-commit rule.
- If calling programmatically, populate the ProjectScopedCommit context before executing the query.
- Catch ExplicitException during query construction and report that the rule requires a commit context.
Example fix
// before "~Fixed in current commit" // evaluated outside commit context // after "~Fixed in commit(1a2b3c4)"
Defensive patterns
Strategy: try-catch
Validate before calling
if (ProjectScopedCommit.get() == null) {
throw new IllegalStateException("Query uses '~Fixed in current commit' but no commit context is active");
} Type guard
boolean canEvaluateFixedInCurrentCommit() {
return ProjectScopedCommit.get() != null;
} Try / catch
try {
Predicate p = criteria.getPredicate(projectScope, query, from, builder);
} catch (ExplicitException e) {
if (e.getMessage().contains("No commit id in query context")) {
// fall back to a context-free query or report to the caller
} else {
throw e;
}
} Prevention
- Only attach commit-relative queries to commit-scoped UI or jobs
- Check ProjectScopedCommit.get() before running queries with context-relative rules
- Rewrite shared queries to reference explicit commit hashes
- Catch ExplicitException at the query-execution boundary
When it happens
Trigger: Running an issue query containing FixedInCurrentCommit and calling getPredicate() (the DB-backed query path) when ProjectScopedCommit.get() returns null.
Common situations: Using a commit-scoped issue query on pages that list issues without a current commit (global issue list, dashboards, REST API queries); copying a query from a commit detail page elsewhere.
Related errors
- No commit in query context
- No issue in query context
- No current pull request in query context
- No current commit in query context
- No build in query context
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/4f86cf85d7555382.
Report an issue: GitHub.