theonedev/onedev · error · ValidationException
Pull request has merge conflicts
Error message
Pull request has merge conflicts
What it means
For job runs on a pull request, OneDev builds the computed merge commit. If the merge preview exists but its mergeCommitHash is null, the PR has merge conflicts and no merge commit can be built, so runBuild throws a ValidationException (HTTP 400).
Source
Thrown at server-core/src/main/java/io/onedev/server/rest/resource/JobRunResource.java:102
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);
var subject = SecurityUtils.getSubject();
var user = SecurityUtils.getUser(subject);View on GitHub (pinned to d44925c47c)
Solutions
- Resolve merge conflicts in the PR branch (rebase/merge target into source and push)
- Check the PR's merge/conflict status in the UI or API before submitting the job run
- Have automation skip or flag conflicted PRs instead of requesting job runs
Example fix
// before runJobOnPullRequest(prId); // 400: Pull request has merge conflicts // after if (getPullRequest(prId).mergePreview.mergeCommitHash != null) runJobOnPullRequest(prId);
Defensive patterns
Strategy: validation
Validate before calling
const preview = getPullRequest(id).mergePreview;
if (preview && preview.mergeCommitHash == null) skip('PR has merge conflicts'); Try / catch
try { runBuild(pr); } catch (WebApplicationException e) { if (msg contains 'merge conflicts') notifyAuthorsToResolve(); else throw e; } Prevention
- Check PR mergeability before triggering builds
- Keep PR branches rebased on target
- Route conflicted PRs to a manual triage path in automation
When it happens
Trigger: Submitting a job run on a pull request whose source and target branches conflict (merge preview calculated but conflict detected).
Common situations: Target branch advanced with overlapping changes; long-lived PRs that drifted from main; automation triggering builds without checking PR mergeable status.
Related errors
- Pull request is closed
- Pull request merge preview not calculated yet
- 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/87cd82197b6713e5.
Report an issue: GitHub.