theonedev/onedev · error · ExplicitException
No build in query context
Error message
No build in query context
What it means
FixedInCurrentBuildCriteria delegates to FixedInBuildCriteria using the build from the current query context. Its getPredicate() requires Build.get() to return a build; when the query is executed without build context, an ExplicitException with this message is thrown because there is no build to scope the 'fixed in current build' criteria to.
Source
Thrown at server-core/src/main/java/io/onedev/server/search/entity/issue/FixedInCurrentBuildCriteria.java:24
import javax.persistence.criteria.From;
import javax.persistence.criteria.Predicate;
import io.onedev.commons.utils.ExplicitException;
import io.onedev.server.model.Build;
import io.onedev.server.model.Issue;
import io.onedev.server.util.ProjectScope;
import io.onedev.server.util.criteria.Criteria;
public class FixedInCurrentBuildCriteria 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 (Build.get() != null)
return new FixedInBuildCriteria(Build.get()).getPredicate(projectScope, query, from, builder);
else
throw new ExplicitException("No build in query context");
}
@Override
public boolean matches(Issue issue) {
if (Build.get() != null)
return new FixedInBuildCriteria(Build.get()).matches(issue);
else
throw new ExplicitException("No build in query context");
}
@Override
public String toStringWithoutParens() {
return IssueQuery.getRuleName(IssueQueryLexer.FixedInCurrentBuild);
}
}
View on GitHub (pinned to d44925c47c)
Solutions
- Execute the query in a build-bound context (build issue list or code that sets Build)
- Replace 'fixed in current build' with 'fixed in build <number>' or an explicit commit range
- Catch ExplicitException programmatically and fall back to a context-free query
- Ensure the integration binds the current build before evaluating issue queries
Example fix
// before
IssueQuery query = IssueQuery.parse("fixed in current build");
issueManager.query(project, query); // throws without build context
// after
Build build = Build.get();
IssueQuery query = IssueQuery.parse(build!=null ? "fixed in current build" : "fixed in build "+buildNumber);
issueManager.query(project, query); Defensive patterns
Strategy: try-catch
Validate before calling
if (Build.get() == null) { throw new IllegalStateException("'fixed in current build' criteria requires build context"); } Type guard
boolean hasBuildContext() { return Build.get() != null; } Try / catch
try { issues = issueManager.query(project, query); } catch (ExplicitException e) { if (e.getMessage().contains("build")) { issues = queryWithoutCurrentBuildCriteria(); } else { throw e; } } Prevention
- Check Build.get() before running 'fixed in current build' queries
- Use 'fixed in build <number>' in saved/dashboard queries
- Only run this criteria from build-scoped pages or CI jobs
- Bind the current Build before programmatic query evaluation
When it happens
Trigger: Running an issue query containing 'fixed in current build' criteria outside a build context — project issue list, saved dashboard query, REST API call, or scheduled evaluation.
Common situations: Filters authored on a build's issue page reused globally; CI scripts issuing queries before a Build entity is registered; cron jobs evaluating queries without build scope.
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/5dd93b6d46de8a8e.
Report an issue: GitHub.