theonedev/onedev · error · ExplicitException
No pull request in query context
Error message
No pull request in query context
What it means
For a PullRequestChoiceField with the 'is current' operator, the matches() evaluation reads PullRequest.get() from the query context. Without a current pull request bound, an ExplicitException is thrown since there is nothing to compare the field value against.
Source
Thrown at server-core/src/main/java/io/onedev/server/search/entity/issue/FieldOperatorCriteria.java:149
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();
if (build != null) {
return build.getProject().equals(issue.getProject())
&& build.getStreamPreviousNumbers(Criteria.IN_CLAUSE_LIMIT)
.stream()
.anyMatch(it->it.equals(fieldValue));
} else {View on GitHub (pinned to d44925c47c)
Solutions
- Run the query within a pull request context (PR issue list or code that sets PullRequest)
- Replace 'is current pull request' with an explicit PR number criteria
- Catch ExplicitException and fall back to an alternative query when no PR context exists
- Ensure the calling integration binds the PR into the query context first
Example fix
// before
IssueQuery query = IssueQuery.parse("\"Pull Request\" is current pull request");
issues.stream().filter(query::matches); // throws without PR
// after
PullRequest pr = PullRequest.get();
IssueQuery query = IssueQuery.parse("\"Pull Request\" is "+(pr!=null?"current pull request":pr.getNumber())); Defensive patterns
Strategy: try-catch
Validate before calling
if (PullRequest.get() == null) { throw new IllegalStateException("'is current pull request' criteria requires PR context"); } Type guard
boolean hasPullRequestContext() { return PullRequest.get() != null; } Try / catch
try { result = issues.stream().filter(query::matches).collect(toList()); } catch (ExplicitException e) { if (e.getMessage().contains("pull request")) { result = fallback(); } else { throw e; } } Prevention
- Verify PullRequest.get() before matching PR-dependent criteria
- Prefer explicit PR numbers in saved filters
- Run PR-dependent queries only in PR-scoped integrations
- Bind the PR into context in webhook/event handlers before querying
When it happens
Trigger: Running an in-memory matches() evaluation of a query containing a PullRequestChoiceField 'is current pull request' criteria outside any pull request context — global issue list, REST API, scheduled evaluation.
Common situations: Filters authored on a PR issue page reused from the project issue list; automation evaluating issue queries without PR context; webhook handlers running queries for events lacking PR 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 issue in query context
- No current pull request in query context
- No current commit in query context
- No build in query context
- No commit in query context
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/f7f9796164fcf641.
Report an issue: GitHub.