theonedev/onedev · error · ExplicitException
No commit in query context
Error message
No commit in query context
What it means
When a CommitField criteria with 'is current' is evaluated via matches(), the engine fetches ProjectScopedCommit.get() from the context. If no commit is bound, an ExplicitException is thrown because the current commit is undefined.
Source
Thrown at server-core/src/main/java/io/onedev/server/search/entity/issue/FieldOperatorCriteria.java:155
} else if (operator == IssueQueryLexer.IsCurrent) {
if (getFieldSpec() instanceof BuildChoiceField) {
Build build = Build.get();
if (build != null)
return build.getProject().equals(issue.getProject()) && build.getId().toString().equals(fieldValue);
else
throw new ExplicitException(_T("No build in query context"));
} else if (getFieldSpec() instanceof PullRequestChoiceField) {
PullRequest request = PullRequest.get();
if (request != null)
return request.getTargetProject().equals(issue.getProject()) && request.getId().toString().equals(fieldValue);
else
throw new ExplicitException(_T("No pull request in query context"));
} else if (getFieldSpec() instanceof CommitField) {
ProjectScopedCommit commit = ProjectScopedCommit.get();
if (commit != null)
return commit.getProject().equals(issue.getProject()) && commit.getCommitId().name().equals(fieldValue);
else
throw new ExplicitException(_T("No commit in query context"));
} else {
throw new IllegalStateException();
}
} else if (operator == IssueQueryLexer.IsPrevious) {
if (getFieldSpec() instanceof BuildChoiceField) {
Build build = Build.get();
if (build != null) {
return build.getProject().equals(issue.getProject())
&& build.getStreamPreviousNumbers(Criteria.IN_CLAUSE_LIMIT)
.stream()
.anyMatch(it->it.equals(fieldValue));
} else {
throw new ExplicitException(_T("No build in query context"));
}
} else {
throw new IllegalStateException();
}
} else {View on GitHub (pinned to d44925c47c)
Solutions
- Evaluate within a commit-bound context or bind ProjectScopedCommit before evaluation
- Replace 'is current commit' with an explicit commit hash in the query
- Catch ExplicitException and degrade gracefully (skip criteria or use default filter)
- Check the calling integration passes the current commit into the query context
Example fix
// before
IssueQuery query = IssueQuery.parse("\"Commit\" is current commit");
issues.stream().filter(query::matches); // throws without commit
// after
if (ProjectScopedCommit.get() == null) {
query = IssueQuery.parse("\"Commit\" is "+commitId.name());
}
issues.stream().filter(query::matches); Defensive patterns
Strategy: try-catch
Validate before calling
if (ProjectScopedCommit.get() == null) { throw new IllegalStateException("'is current commit' criteria requires commit context"); } Type guard
boolean hasCommitContext() { return ProjectScopedCommit.get() != null; } Try / catch
try { result = issues.stream().filter(query::matches).collect(toList()); } catch (ExplicitException e) { if (e.getMessage().contains("commit")) { result = fallbackQuery(); } else { throw e; } } Prevention
- Check ProjectScopedCommit.get() before commit-dependent matching
- Use explicit commit hashes outside commit-scoped pages
- Pass the current commit into background evaluations
- Test criteria in all execution contexts used in production
When it happens
Trigger: Evaluating an issue query with a CommitField 'is current commit' criteria outside a commit-scoped context — project issue list, REST call, background job.
Common situations: Commit-scoped saved queries reused elsewhere; CI scripts running issue queries without passing the checked-out commit; queries triggered from non-commit pages.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- No issue in query context
- No current pull request in query context
- No current commit in query context
- No build in query context
- No pull request in query context
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/e65e145839e1bbae.
Report an issue: GitHub.