theonedev/onedev · error · ValidationException
Pull request merge preview not calculated yet
Error message
Pull request merge preview not calculated yet
What it means
When running a job on a pull request, runBuild calls request.checkMergePreview(). If the merge preview has not been computed yet by the background merge-preview calculation, it returns null and the endpoint throws a ValidationException (HTTP 400). OneDev cannot determine which merge commit to build against.
Source
Thrown at server-core/src/main/java/io/onedev/server/rest/resource/JobRunResource.java:100
commitId = ObjectId.fromString(jobRunOnCommit.getCommitHash());
if (!gitService.isMergedInto(project, null, commitId, refCommit))
throw new ValidationException("Specified commit is not reachable from specified ref");
refName = jobRunOnCommit.getRefName();
request = null;
} else {
JobRunOnPullRequest jobRunOnPullRequest = (JobRunOnPullRequest) jobRun;
request = pullRequestService.load(jobRunOnPullRequest.getPullRequestId());
refName = request.getMergeRef();
project = request.getProject();
if (!SecurityUtils.canRunJob(subject, request.getProject(), jobRun.getJobName()))
throw new UnauthorizedException();
MergePreview preview = request.checkMergePreview();
if (preview == null)
throw new ValidationException("Pull request merge preview not calculated yet");
if (preview.getMergeCommitHash() == null)
throw new ValidationException("Pull request has merge conflicts");
commitId = ObjectId.fromString(preview.getMergeCommitHash());
}
Build build = jobService.submit(user, project, commitId, jobRun.getJobName(),
jobRun.getParams(), refName, request, null, jobRun.getReason());
if (build.isFinished())
jobService.resubmit(user, build, jobRun.getReason());
return build.getId();
}
@Api(order=200)
@Path("/rebuild")
@POST
public Response rebuild(@NotNull @Valid JobRerun jobRerun) {
Build build = buildService.load(jobRerun.buildId);View on GitHub (pinned to d44925c47c)
Solutions
- Wait/retry until the pull request shows a calculated merge preview in the UI, then resubmit
- Trigger a merge preview recalculation (open/refresh the PR) and retry after a short delay
- Add retry-with-backoff around the API call in automation scripts
Example fix
// before runJobOnPullRequest(prId); // throws if preview not ready // after await pollUntilPrMergePreviewReady(prId, timeout=60s); runJobOnPullRequest(prId);
Defensive patterns
Strategy: retry
Validate before calling
// poll PR merge preview before submitting while (getPullRequest(id).mergePreview == null && elapsed < timeout) sleep(backoff);
Try / catch
try { runBuild(pr); } catch (WebApplicationException e) { if (msg contains 'not calculated yet') retryWithBackoff(); else throw e; } Prevention
- Delay job submission after PR creation/update until preview is shown
- Use exponential backoff in automation
- Avoid racing the server's background merge-preview calculation
When it happens
Trigger: Submitting a job run on a pull request immediately after the PR was created or freshly updated, before OneDev finished calculating the merge preview.
Common situations: API automation racing PR creation; server under load delaying merge preview calculation; calling right after a push that invalidated the previous preview.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Pull request is closed
- Pull request has merge conflicts
- Reviewer needs to have read code permission to the project
- Assignee needs to have write code permission to the project
- This pull request is not eligible for auto-merge, as it can
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/af0cf644ea346a50.
Report an issue: GitHub.