theonedev/onedev · error · NotAcceptableException

You are not reviewer of this pull request. Add your option a

Error message

You are not reviewer of this pull request. Add your option as comment instead

What it means

Thrown by DefaultPullRequestReviewService.review when the acting user is not an assigned reviewer (or their review was EXCLUDED) on the pull request. Only invited reviewers can record approve/request-changes verdicts; everyone else must voice their opinion via comments. It surfaces as a NotAcceptableException (HTTP 405/400-class client error).

Source

Thrown at server-core/src/main/java/io/onedev/server/service/impl/DefaultPullRequestReviewService.java:80

		
		Root<PullRequestReview> root = query.from(PullRequestReview.class);
		query.select(root);
		Join<PullRequest, PullRequest> join = root.join(PullRequestReview.PROP_REQUEST);
		query.where(join.in(requests));
		
		for (PullRequest request: requests) 
			request.setReviews(new ArrayList<>());
		
		for (PullRequestReview review: getSession().createQuery(query).getResultList())
			review.getRequest().getReviews().add(review);
	}
 	
	@Transactional
	@Override
	public void review(User user, PullRequest request, boolean approved, String note) {
		PullRequestReview review = request.getReview(user);
		if (review == null || review.getStatus() == PullRequestReview.Status.EXCLUDED)
			throw new NotAcceptableException("You are not reviewer of this pull request. Add your option as comment instead");

		if (approved)
			review.setStatus(PullRequestReview.Status.APPROVED);
		else
			review.setStatus(PullRequestReview.Status.REQUESTED_FOR_CHANGES);
			
		createOrUpdate(user, review);
		
		PullRequestChange change = new PullRequestChange();
		change.setDate(review.getStatusDate());
		change.setRequest(request);
		change.setUser(user);
		if (approved)
			change.setData(new PullRequestApproveData());
		else
			change.setData(new PullRequestRequestedForChangesData());
		
		changeService.create(change, note);

View on GitHub (pinned to d44925c47c)

Solutions

  1. Have the PR author or a project admin add the user as a reviewer, then call review again
  2. If the user should not be a reviewer, post their feedback as a comment on the pull request instead
  3. Check request.getReview(user) before calling review to detect the null/EXCLUDED case
  4. Verify you are authenticating as the intended user (token/account mix-up)

Example fix

// before
reviewService.review(user, request, true, "LGTM"); // 405 if not reviewer
// after
if (request.getReview(user) != null && request.getReview(user).getStatus() != PullRequestReview.Status.EXCLUDED)
    reviewService.review(user, request, true, "LGTM");
else
    commentService.comment(user, request, "LGTM"); // add as comment instead
Defensive patterns

Strategy: try-catch

Validate before calling

PullRequestReview review = request.getReview(currentUser);
boolean canReview = review != null && review.getStatus() != PullRequestReview.Status.EXCLUDED;

Type guard

boolean isReviewer(PullRequest request, User user) {
    PullRequestReview r = request.getReview(user);
    return r != null && r.getStatus() != PullRequestReview.Status.EXCLUDED;
}

Try / catch

try {
    reviewService.review(user, request, approved, note);
} catch (NotAcceptableException e) {
    // fall back to posting a comment instead
}

Prevention

When it happens

Trigger: Calling review(user, request, approved, note) (directly or via REST endpoint) when request.getReview(user) returns null or a review whose status is PullRequestReview.Status.EXCLUDED — i.e. user was never added as a reviewer or was removed/excluded from review.

Common situations: A developer tries to approve a colleague's PR via API without being added to the reviewer list; a reviewer was excluded by a code-compliance rule and then attempts to re-approve; scripting against the REST resource with a non-reviewer account.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


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