theonedev/onedev · error · ExplicitException
No build in query context
Error message
No build in query context
What it means
When an issue criteria uses a BuildChoiceField with the 'is current' operator, the in-memory matches() evaluation reads Build.get() from the query context. If no build is bound, an ExplicitException is thrown because the criteria cannot compare against a current build.
Source
Thrown at server-core/src/main/java/io/onedev/server/search/entity/issue/FieldOperatorCriteria.java:143
else
return fieldValue == null;
} else if (operator == IssueQueryLexer.IsMe) {
if (User.get() != null) {
var userName = User.get().getName();
if (fieldValue instanceof Collection)
return ((Collection) fieldValue).contains(userName);
else
return Objects.equals(fieldValue, userName);
} else {
throw new NotAcceptableException(_T("Please login to perform this query"));
}
} 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();View on GitHub (pinned to d44925c47c)
Solutions
- Execute the query in a build-bound context (build issue list or code that sets Build)
- Substitute an explicit build number/id in the query instead of 'is current build'
- Catch ExplicitException and skip or rewrite the criteria when context is absent
- Ensure CI integrations bind the current Build before running issue queries
Example fix
// before
IssueQuery query = IssueQuery.parse("\"Build\" is current build");
issueManager.query(project, query); // throws without build
// after
Build build = Build.get();
IssueQuery query = IssueQuery.parse(build!=null ? "\"Build\" is current build" : "\"Build\" is "+buildNumber); Defensive patterns
Strategy: try-catch
Validate before calling
if (Build.get() == null) { throw new IllegalStateException("'is current build' criteria requires build context"); } Type guard
boolean hasBuildContext() { return Build.get() != null; } Try / catch
try { result = issues.stream().filter(query::matches).collect(toList()); } catch (ExplicitException e) { if (e.getMessage().contains("build")) { result = List.of(); } else { throw e; } } Prevention
- Check Build.get() before in-memory matching of build criteria
- Use explicit build ids in non-CI contexts
- Bind Build before programmatic query evaluation
- Keep build-dependent filters out of globally reused saved queries
When it happens
Trigger: Evaluating a query with a BuildChoiceField 'is current build' criteria via matches() while no Build is set in the context — e.g. the global issue list, REST queries, or background processing without build context.
Common situations: Saved filters from a build page reused on the project issue list; scripts evaluating issue rules outside CI; queries embedded in reports executed server-side.
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 build in query context
- No issue in query context
- No current build in query context
- No current pull request in query context
- No current commit in query context
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/4cb7b2cc80d982dc.
Report an issue: GitHub.