theonedev/onedev · error · EntityNotFoundException
Unable to find pull request #{0} in project {1}
Error message
Unable to find pull request #{0} in project {1} What it means
PullRequestDetailPage looks up the pull request by number in the current project; when pullRequestService.find returns null it throws EntityNotFoundException with this message. The number was valid but no matching pull request exists in that project.
Source
Thrown at server-core/src/main/java/io/onedev/server/web/page/project/pullrequests/detail/PullRequestDetailPage.java:258
if (StringUtils.isBlank(requestNumberString)) {
throw new RestartResponseException(ProjectPullRequestsPage.class,
ProjectPullRequestsPage.paramsOf(getProject(), null, 0));
}
requestModel = new LoadableDetachableModel<>() {
@Override
protected PullRequest load() {
Long requestNumber;
try {
requestNumber = Long.valueOf(requestNumberString);
} catch (NumberFormatException e) {
throw new NotAcceptableException(MessageFormat.format(_T("Invalid pull request number: {0}"), requestNumberString));
}
PullRequest request = pullRequestService.find(getProject(), requestNumber);
if (request == null) {
throw new EntityNotFoundException(MessageFormat.format(_T("Unable to find pull request #{0} in project {1}"), requestNumber, getProject().getPath()));
} else if (!request.getTargetProject().equals(getProject())) {
throw new RestartResponseException(getPageClass(), paramsOf(request));
} else {
return request;
}
}
};
if (!getPullRequest().isValid()) {
throw new RestartResponseException(InvalidPullRequestPage.class,
InvalidPullRequestPage.paramsOf(getPullRequest()));
}
latestUpdateId = requestModel.getObject().getLatestUpdate().getId();
}
private WebMarkupContainer newRequestHead() {View on GitHub (pinned to d44925c47c)
Solutions
- Confirm the PR number exists in this project's pull requests list.
- Check the URL's project path — the PR may belong to a different (e.g. fork) project.
- Use the pull request list or search to obtain the correct link.
Example fix
// before
open("/projects/" + wrongProject + "/~pulls/" + number);
// after
open("/projects/" + request.getTargetProject().getPath() + "/~pulls/" + request.getNumber()); Defensive patterns
Strategy: validation
Validate before calling
PullRequest request = pullRequestService.find(project, number);
if (request == null) throw new IllegalArgumentException("PR #" + number + " not found in " + project.getPath()); Type guard
boolean prExistsInProject(Project p, long number) { return pullRequestService.find(p, number) != null; } Try / catch
try { showPullRequest(number); } catch (EntityNotFoundException e) { renderPrMissing(number); } Prevention
- Verify PR existence in the exact project before linking.
- Use request.getTargetProject() for the authoritative project of a PR.
- Purge or redirect links to deleted pull requests.
When it happens
Trigger: Accessing a PR detail URL whose number does not exist in the project (deleted PR, wrong project, number beyond existing range).
Common situations: Following links from notifications after the PR was deleted; confusing a fork's PR numbers with the target project's numbers; database restored from an older backup while links were newer.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- Unable to find pull request #<n> in project <project>
- Unable to find issue #{0} in project {1}
- Invalid pull request number: {0}
- User not found: ${userName}
- Issue not found: ${referenceString}
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/0ca188df1d227286.
Report an issue: GitHub.