theonedev/onedev · warning · NotAcceptableException

Error validating auto merge commit message:

Error message

Error validating auto merge commit message: 

What it means

Thrown by POST /pull-requests/{requestId}/auto-merge when the provided (or default) merge commit message fails validation. request.checkMergeCommitMessage() returns a non-null error (e.g. message exceeds length limits, contains disallowed placeholders, or violates project commit-message rules) and the endpoint surfaces it as HTTP 406 with prefix 'Error validating auto merge commit message: '.

Source

Thrown at server-core/src/main/java/io/onedev/server/rest/resource/PullRequestResource.java:516

	@POST
	public Response setAutoMerge(@PathParam("requestId") Long requestId, @NotNull AutoMergeData data) {
		var subject = SecurityUtils.getSubject();
		var user = SecurityUtils.getUser(subject);
		PullRequest request = pullRequestService.load(requestId);
		if (!SecurityUtils.canModifyPullRequest(subject, request) || !SecurityUtils.canWriteCode(subject, request.getProject()))
			throw new UnauthorizedException();
		if (!request.isOpen())
			throw new NotAcceptableException("Pull request is closed");

		if (data.isEnabled() && request.checkMergeCondition() == null)
			throw new NotAcceptableException("This pull request is not eligible for auto-merge, as it can be merged directly now");

		var autoMerge = new AutoMerge();
		autoMerge.setEnabled(data.isEnabled());
		autoMerge.setCommitMessage(data.getCommitMessage());
		var errorMessage = request.checkMergeCommitMessage(user, autoMerge.getCommitMessage());
		if (errorMessage != null)
			throw new NotAcceptableException("Error validating auto merge commit message: " + errorMessage);

		pullRequestChangeService.changeAutoMerge(user, request, autoMerge);

		return Response.ok().build();
	}
	
	@Api(order=1600)
	@Path("/{requestId}/reopen")
    @POST
    public Response reopenPullRequest(@PathParam("requestId") Long requestId, String note) {
		PullRequest request = pullRequestService.load(requestId);
		var subject = SecurityUtils.getSubject();
		var user = SecurityUtils.getUser(subject);
    	if (!SecurityUtils.canModifyPullRequest(subject, request))
			throw new UnauthorizedException();
    	
		pullRequestService.reopen(user, request, note);
		return Response.ok().build();

View on GitHub (pinned to d44925c47c)

Solutions

  1. Read the error text after the prefix — it states the exact validation rule violated
  2. Shorten or reformat the commitMessage in AutoMergeData to satisfy project policy
  3. Omit commitMessage entirely to let OneDev use the default merge commit message
  4. Check project settings for merge commit message template/limits and conform to them

Example fix

// before
{enabled: true, commitMessage: longGeneratedTitle + ' -- ' + body5000chars}
// after
{enabled: true, commitMessage: 'Merge pull request #' + id + ' from ' + branch}
Defensive patterns

Strategy: validation

Validate before calling

const msg = buildCommitMessage();
if (!msg || msg.length > 500) { // match project merge-commit policy
  throw new Error('merge commit message violates project policy');
}
post('/~api/pull-requests/' + id + '/auto-merge', {enabled: true, commitMessage: msg})

Type guard

function isValidCommitMessage(msg) {
  return typeof msg === 'string' && msg.trim().length > 0 && msg.length <= 500;
}

Try / catch

try {
  post('/~api/pull-requests/' + id + '/auto-merge', {enabled: true, commitMessage: msg});
} catch (e) {
  if (e.status === 406 && /commit message/i.test(e.body || '')) {
    log('Commit message rejected: ' + (e.body || '').replace(/^.*: /, ''));
  } else throw e;
}

Prevention

When it happens

Trigger: POSTing to /~api/pull-requests/{requestId}/auto-merge with AutoMergeData.commitMessage that violates the project's merge-commit message requirements (too long, empty when required, invalid content).

Common situations: Scripts generating commit messages with special characters or exceeding server limits; passing the PR title verbatim when project policy requires a fixed format; locale/encoding issues making the message contain unexpected characters.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/da4b5055b2987f78. Report an issue: GitHub.