Let approvers below Developer request changes

What does this MR do and why?

Follows !266048 (merged), which lets members below Developer set their reviewer state to reviewed. Request changes still needs Developer there. This MR lets anyone who can approve a merge request also request changes on it, so Planners and Reporters in an approval rule can block as well as approve. A reviewer who can't approve can't block a merge request they could never unblock by approving.

When someone who can't approve submits a review with Request changes, the review is still posted as reviewed and they're told why. The explicit request changes mutation and /request_changes return an error. GitLab Duo Code Review is unaffected; other agent flows follow the same rules. See Duo Code Review and agent flows below.

Screenshots

Reporter who can't approve Reporter who can approve (group approval rule)
Approve and Request changes are disabled: after-reporter-drawer-no-approve Request changes is available: after-reporter-drawer-approver
After submitting, the Reporter's requested changes block merge: after-sidebar-reporter-requested-changes
Changes, Duo Code Review and agent flows, and verification

Changes

  • UpdateReviewerStateService: requested_changes needs create_merge_request_review and approve_merge_request instead of update_merge_request. Developers always have both, Planners and Reporters only when an approval rule includes them, and Guests never. A refusal returns a specific message, which review submissions (from !266048 (merged)) return as the reviewed fallback warning.
  • bulk_publish publishes the review and falls back to reviewed, returning 204 as before. /submit_review requested_changes and the review drawer show the message. /request_changes and mergeRequestRequestChanges return it as an error.
  • DestroyRequestedChangesService checks create_merge_request_review, so anyone who requested changes can withdraw them, even if they can no longer approve.
  • MergeRequestRequestChanges and MergeRequestDestroyRequestedChanges inherit BaseMutation with inline arguments, like MergeRequestSetSubscription, and authorize create_merge_request_review. Mutations::MergeRequests::Base adds update_merge_request to every subclass, so they can't stay on it. Granular tokens use create_merge_request_review, which is in the update_merge_request assignable permission.
  • Review drawer: Request changes is disabled when the user can neither update the merge request nor approve it, and, like Approve, on merged merge requests. canApprove reports approval eligibility (false after you approve), so the drawer also checks approvedBy: Developers keep the option through updateMergeRequest, and approvers below Developer keep it after approving. The fallback warning covers what the drawer can't see: a non-member author, who holds update_merge_request, and a page loaded before permissions changed.
  • Docs: the approval requirement and the fallback under Prevent merge when you request changes, and the Request changes row in the permissions table.

Duo Code Review and agent flows

Duo Code Review is unaffected. Classic and Code Review Flow both publish as duo_code_review_bot. Code Review Flow sends its output to POST /ai/duo_workflows/code_review/add_comments, and PublishCommentsWorker publishes the notes and applies the review decision as the bot (CreateCommentsService). EE treats the bot as a Developer on every project regardless of membership or license, and it passes create_merge_request_review and approve_merge_request as a non-member. The new EE service spec covers reviewed and requested_changes for it.

Other agent flows follow the new rules. Flows that call bulk_publish through composite identity, such as the Security Review flow's submit_mr_review tool, are checked as both the service account and the human they act for. On GitLab.com in the last 7 days, those calls sent reviewed 565 times and requested_changes 73 times. On master, a flow's requested_changes records a merge block under the human's name whenever that human has update_merge_request, including non-member MR authors. With this MR it needs the human to be a member who can approve. Agent flows couldn't approve before and still can't: bulk_publish rejects approved, and all 4 composite-identity calls to the REST approve endpoint in the last 7 days returned 403.

Agent flows get the same fallback. A refused requested_changes from a flow publishes its review as reviewed, and bulk_publish returns 204, so the AI Gateway tool doesn't raise and nothing is posted twice. The flow's own reviewer state is set to reviewed after a fallback, otherwise to the requested state as on master. A refusal that can't fall back (an author-triggered review has no reviewer row for the human) still returns the warning to the drawer and /submit_review, but doesn't change the flow's own state.

Behavior changes

  • Only users who can approve can request changes. Developers are unaffected.
  • Requesting changes without approval rights submits the review as reviewed, with a warning in the drawer and /submit_review, instead of a silent no-op.
  • Non-member authors and assignees can no longer request changes or withdraw them, directly or through an agent flow acting for them.

Verification

  • Service (including a non-member author and duo_code_review_bot as a non-member), bulk_publish fallback (including the composite identity's own state), /submit_review message, both GraphQL mutations, DestroyRequestedChangesService, and review drawer specs (including the merged state).
  • A Reporter in a group approval rule can approve and request changes, tested in the EE service spec with a real approval rule.
  • In GDK, Reporter, Planner, and Security Manager reviewers who can't approve are refused requested_changes. With a group approval rule they can request changes, and it blocks merge.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist.

Edited by Kai Armstrong

Merge request reports

Loading
Loading