theonedev/onedev · error · NotAcceptableException
Error checking merge commit message: ${errorMessage}
Error message
Error checking merge commit message: ${errorMessage} What it means
merge throws "Error checking merge commit message: <reason>" when PullRequest.checkMergeCommitMessage(user, commitMessage) rejects the supplied commit message. This runs when the merge strategy requires a merge commit message and the branch protection of the target branch enforces commit message rules (pattern/length), validated via branchProtection.checkCommitMessage.
Source
Thrown at server-core/src/main/java/io/onedev/server/service/impl/DefaultPullRequestService.java:359
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;
else
author = null;
if (commitMessage == null)View on GitHub (pinned to d44925c47c)
Solutions
- Supply a commitMessage that satisfies the target branch's branch-protection commit message rules
- Pass null to use getDefaultMergeCommitMessage() if that default passes the rules
- Fix the auto-merge configuration so its commit message complies with branch protection
- Pre-check request.checkMergeCommitMessage(user, commitMessage) == null before merging
Example fix
// before
prService.merge(user, "update"); // 400: message fails branch protection pattern
// after
String msg = request.checkMergeCommitMessage(user, "update") == null
? "update"
: request.getDefaultMergeCommitMessage();
prService.merge(user, msg); Defensive patterns
Strategy: validation
Validate before calling
String err = request.checkMergeCommitMessage(user, commitMessage); boolean messageOk = err == null;
Try / catch
try {
prService.merge(user, commitMessage);
} catch (NotAcceptableException e) {
// message begins with "Error checking merge commit message:"
} Prevention
- Match the target branch's commit message rules when composing messages
- Use getDefaultMergeCommitMessage() when unsure
- Keep auto-merge commit message templates compliant with branch protection
When it happens
Trigger: Calling DefaultPullRequestService.merge(user, commitMessage) with a commitMessage that violates the target branch's protection rules when isMergeCommitMessageRequired() is true (merge strategy SQUASH_SOURCE_BRANCH_COMMITS or CREATE_MERGE_COMMIT, or a necessary merge commit). Also fires via checkAutoMerge when the configured auto-merge commit message is non-compliant.
Common situations: Branch protection requires commit messages matching a regex and the caller passes a plain message; auto-merge configured with a commit message template that fails branch protection; squash merges omitting required message elements.
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
- errorMessage (from checkMergeCondition)
- Error validating param auto merge commit message:
- Not authorized
- Pull request is closed
- Error validating auto merge commit message:
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/553f121557668394.
Report an issue: GitHub.