theonedev/onedev · error · NotAcceptableException

errorMessage (from checkReopenCondition)

Error message

errorMessage (from checkReopenCondition)

What it means

reopen throws the message from PullRequest.checkReopenCondition() as a NotAcceptableException when the PR cannot be reopened. Guards include: PR already open, target/source branch or source project missing, another effective PR already covers the same change (open or already merged), or the source branch is already merged into the target. The thrown message equals the condition error text.

Source

Thrown at server-core/src/main/java/io/onedev/server/service/impl/DefaultPullRequestService.java:316

            throw new NotAcceptableException(errorMessage);

		if (request.getSource().getObjectName(false) != null) {
			projectService.deleteBranch(request.getSourceProject(), request.getSourceBranch());
			PullRequestChange change = new PullRequestChange();
			change.setDate(new Date());
			change.setData(new PullRequestSourceBranchDeleteData());
			change.setRequest(request);
			change.setUser(user);
			changeService.create(change, note);
		}
	}

	@Transactional
	@Override
	public void reopen(User user, PullRequest request, String note) {
        var errorMessage = request.checkReopenCondition();
        if (errorMessage != null)
            throw new NotAcceptableException(errorMessage);

		request.setStatus(OPEN);

		PullRequestChange change = new PullRequestChange();
		change.setData(new PullRequestReopenData());
		change.setRequest(request);
		change.setUser(user);
		changeService.create(change, note);

		MergePreview mergePreview = request.checkMergePreview();
		if (mergePreview != null)
			updateMergePreviewRef(request);

		checkAsync(request, false, true);
	}

	@Transactional
	@Override

View on GitHub (pinned to d44925c47c)

Solutions

  1. If already open, skip the reopen call
  2. Restore the missing source/target branch (or source project) before reopening
  3. If changes are already merged or another PR covers them, open a new PR for new work instead
  4. Pre-check request.checkReopenCondition() == null before calling reopen

Example fix

// before
prService.reopen(user, request, "reopen it"); // 400 "Source branch no longer exists"
// after
if (request.checkReopenCondition() == null)
    prService.reopen(user, request, "reopen it");
Defensive patterns

Strategy: validation

Validate before calling

String err = request.checkReopenCondition();
boolean canReopen = err == null;

Try / catch

try {
    prService.reopen(user, request, note);
} catch (NotAcceptableException e) {
    // decide: already open / branches missing / already merged
}

Prevention

When it happens

Trigger: Calling DefaultPullRequestService.reopen(user, request, note) when checkReopenCondition() returns non-null — e.g. "Pull request already opened", "Target branch no longer exists", "Source branch no longer exists", "Another pull request already open for this change", "Change already merged", or "Source branch already merged into target branch".

Common situations: Reopening a discarded PR after its branches were deleted; the changes were already merged via another PR; a duplicate open PR exists for the same source->target pair; fork source repository was removed.

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


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