theonedev/onedev · error · ExplicitException
No project in query context
Error message
No project in query context
What it means
ProjectIsCurrentCriteria.getPredicate matches the pseudo-criterion 'project is current', comparing against Project.get(), the project bound to the current context. With no project in context it throws ExplicitException 'No project in query context' because the criterion cannot be evaluated.
Source
Thrown at server-core/src/main/java/io/onedev/server/search/entity/issue/ProjectIsCurrentCriteria.java:25
import javax.persistence.criteria.JoinType;
import javax.persistence.criteria.Predicate;
import io.onedev.commons.utils.ExplicitException;
import io.onedev.server.model.Issue;
import io.onedev.server.model.Project;
import io.onedev.server.util.ProjectScope;
import io.onedev.server.util.criteria.Criteria;
public class ProjectIsCurrentCriteria 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 (Project.get() != null)
return builder.equal(from.join(Issue.PROP_PROJECT, JoinType.INNER), Project.get());
else
throw new ExplicitException("No project in query context");
}
@Override
public boolean matches(Issue issue) {
if (Project.get() != null)
return Project.get().equals(issue.getProject());
else
throw new ExplicitException("No project in query context");
}
@Override
public String toStringWithoutParens() {
return quote(Issue.NAME_PROJECT) + " "
+ IssueQuery.getRuleName(IssueQueryLexer.IsCurrent);
}
}
View on GitHub (pinned to d44925c47c)
Solutions
- Run the query within a project scope (include project in URL/request).
- Replace 'is current' in the query with an explicit 'project is <name>' criterion.
- Bind Project context (Project.set) if executing programmatically.
- Catch ExplicitException and fall back to a project-scoped query path.
Example fix
// before query: "project is current" (run at global scope) // after query: "project is myproject"
Defensive patterns
Strategy: validation
Validate before calling
// Ensure project scope before running 'is current' queries
if (Project.get() == null)
throw new ExplicitException("Query uses 'project is current'; run within a project scope"); Type guard
Project current = Project.get(); boolean projectScoped = current != null;
Try / catch
try {
Predicate p = criteria.getPredicate(projectScope, query, from, builder);
} catch (ExplicitException e) {
throw new QueryContextException(e.getMessage());
} Prevention
- Only expose 'is current' criteria in project-scoped query builders.
- Substitute explicit project names in queries saved for global use.
- Bind Project context when evaluating queries in services/tests.
When it happens
Trigger: Running an issue query containing the 'is current' project criterion outside any project scope (Project.get() == null), e.g. global issue search or unscoped REST query.
Common situations: Saved queries containing 'project is current' reused from a global/dashboard context; API calls lacking the project path segment; embedded issue lists outside a project page.
Related errors
- Please login to perform this query
- No branch in query context
- Please login to perform this query
- No issue in query context
- No current build in query context
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/38c3d3819e0e36d5.
Report an issue: GitHub.