theonedev/onedev · error · NotAcceptableException
errorMessage (from checkMergeCondition)
Error message
errorMessage (from checkMergeCondition)
What it means
merge throws the message returned by PullRequest.checkMergeCondition() as a NotAcceptableException when the PR does not satisfy merge requirements. Possible causes include: PR closed, PR in error state, work-in-progress, merge preview missing, merge conflicts, missing approvals, required builds not passed, missing commit signature, commit message policy violations, or disallowed file types.
Source
Thrown at server-core/src/main/java/io/onedev/server/service/impl/DefaultPullRequestService.java:356
request.setStatus(Status.DISCARDED);
request.setCloseDate(new Date());
PullRequestChange change = new PullRequestChange();
change.setData(new PullRequestDiscardData());
change.setRequest(request);
change.setUser(user);
changeService.create(change, note);
pendingSuggestionApplyService.discard(null, request);
}
@Transactional
@Override
public void merge(User user, PullRequest request, @Nullable String commitMessage) {
var errorMessage = request.checkMergeCondition();
if (errorMessage != null)
throw new NotAcceptableException(errorMessage);
errorMessage = request.checkMergeCommitMessage(user, commitMessage);
if (errorMessage != null)
throw new NotAcceptableException("Error checking merge commit message: " + errorMessage);
MergePreview mergePreview = checkNotNull(request.checkMergePreview());
ObjectId mergeCommitId = ObjectId.fromString(checkNotNull(mergePreview.getMergeCommitHash()));
PersonIdent person = user.asPerson();
Project project = request.getTargetProject();
MergeStrategy mergeStrategy = mergePreview.getMergeStrategy();
if (mergeStrategy == CREATE_MERGE_COMMIT
|| mergeStrategy == SQUASH_SOURCE_BRANCH_COMMITS
|| mergeStrategy == CREATE_MERGE_COMMIT_IF_NECESSARY
&& !mergeCommitId.name().equals(mergePreview.getHeadCommitHash())) {
PersonIdent author;
if (mergeStrategy != SQUASH_SOURCE_BRANCH_COMMITS)
author = person;View on GitHub (pinned to d44925c47c)
Solutions
- Resolve the specific reported condition: get approvals, let required builds pass, resolve conflicts, or remove WIP marker
- Ensure merge preview is computed (wait for the PR update) before merging
- Verify commit messages and file types comply with target-branch protection rules
- Pre-check request.checkMergeCondition() == null before calling merge
Example fix
// before
prService.merge(user, null); // 400 "Waiting for approvals"
// after
if (request.checkMergeCondition() == null)
prService.merge(user, null);
else
log.info("merge blocked: " + request.checkMergeCondition()); Defensive patterns
Strategy: validation
Validate before calling
String err = request.checkMergeCondition(); boolean canMerge = err == null;
Try / catch
try {
prService.merge(user, commitMessage);
} catch (NotAcceptableException e) {
// message states the blocking condition (approvals, builds, conflicts, ...)
} Prevention
- Check checkMergeCondition() before merge and surface the reason
- Wait for required builds and approvals
- Keep the branch up to date to avoid conflicts
- Ensure commit message and file-type policies are satisfied
When it happens
Trigger: Calling DefaultPullRequestService.merge(user, commitMessage) (directly, via REST, or via checkAutoMerge) when checkMergeCondition() returns non-null — e.g. "There are merge conflicts", "Waiting for approvals", "Some required builds not passed", "Pull request is work in progress".
Common situations: Merging before required CI builds finish; missing reviewer approvals; merge conflicts introduced by new target-branch commits; WIP-titled PRs; branch protection requiring signed commits or specific commit message patterns; file-type restrictions on the target branch.
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
- Error checking merge commit message: ${errorMessage}
- Not authorized
- Pull request is closed
- Cannot delete pull request "${request.getReference().toStrin
- errorMessage (from checkRestoreSourceBranchCondition)
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/f0145eeb9bb74ffb.
Report an issue: GitHub.