theonedev/onedev · error · ExplicitException
No current commit in query context
Error message
No current commit in query context
What it means
When an issue query criteria uses a CommitField with an operator whose value depends on the current commit, the engine looks up ProjectScopedCommit.get() from the evaluation context. If no commit is bound (query executed outside a commit-scoped context), an ExplicitException is thrown because the criteria value cannot be determined.
Source
Thrown at server-core/src/main/java/io/onedev/server/search/entity/issue/FieldOperatorCriteria.java:90
throw new ExplicitException(_T("No current build in query context"));
}
} else if (getFieldSpec() instanceof PullRequestChoiceField) {
PullRequest request = PullRequest.get();
if (request != null) {
return builder.and(
builder.equal(projectAttribute, request.getTargetProject()),
builder.equal(valueAttribute, String.valueOf(request.getNumber())));
} else {
throw new ExplicitException(_T("No current pull request in query context"));
}
} else if (getFieldSpec() instanceof CommitField) {
ProjectScopedCommit commit = ProjectScopedCommit.get();
if (commit != null) {
return builder.and(
builder.equal(projectAttribute, commit.getProject()),
builder.equal(valueAttribute, commit.getCommitId().name()));
} else {
throw new ExplicitException(_T("No current commit in query context"));
}
} else {
throw new IllegalStateException();
}
} else if (operator == IssueQueryLexer.IsPrevious) {
if (getFieldSpec() instanceof BuildChoiceField) {
Build build = Build.get();
if (build != null) {
Collection<Long> streamPreviousNumbers = Build.get().getStreamPreviousNumbers(Criteria.IN_CLAUSE_LIMIT);
if (!streamPreviousNumbers.isEmpty()) {
return builder.and(
builder.equal(projectAttribute, build.getProject()),
valueAttribute.in(streamPreviousNumbers.stream().map(it->it.toString()).collect(Collectors.toSet())));
} else {
return builder.disjunction();
}
} else {
throw new ExplicitException(_T("No current build in query context"));View on GitHub (pinned to d44925c47c)
Solutions
- Execute the query from a commit-scoped context (commit page or code path that sets ProjectScopedCommit)
- Replace the 'is current commit' criteria with an explicit commit hash value in the query
- Catch ExplicitException programmatically and degrade to a query without the commit criteria
- Ensure the integration code binds ProjectScopedCommit before calling the query engine
Example fix
// before
IssueQuery query = IssueQuery.parse("\"Commit\" is current");
issueManager.query(project, query); // throws outside commit context
// after
if (ProjectScopedCommit.get() == null) {
query = IssueQuery.parse("\"Commit\" is "+commitId.name());
}
issueManager.query(project, query); Defensive patterns
Strategy: try-catch
Validate before calling
if (ProjectScopedCommit.get() == null) { throw new IllegalStateException("Query with 'is current commit' requires commit context"); } Type guard
boolean hasCommitContext() { return ProjectScopedCommit.get() != null; } Try / catch
try { issues = issueManager.query(project, query); } catch (ExplicitException e) { if (e.getMessage().contains("current commit")) { issues = fallbackQuery(); } else { throw e; } } Prevention
- Verify ProjectScopedCommit.get() before evaluating commit-dependent criteria
- Use explicit commit hashes in saved queries
- Pass the checked-out commit into any CI-side query evaluation
- Test saved queries in all contexts where they will run
When it happens
Trigger: Evaluating an issue query with a CommitField 'is current' style criteria while no ProjectScopedCommit is set in the current context — e.g. querying from the project issue list, REST API, or a build script where the commit context was never established.
Common situations: Saved queries referencing the current commit reused from a dashboard; CI pipelines executing issue queries without passing the checked-out commit; using the query in a context menu outside the commit page.
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 build in query context
- No pull request in query context
- No commit in query context
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/016f3d0d11c1e00b.
Report an issue: GitHub.