fix(mr): warn when publishing --reviewer-state on your own merge request

Description

glab mr note publish --reviewer-state ... silently did nothing when the caller is the MR author and not one of its reviewers: GitLab's bulk_publish endpoint returns 204 but discards the result of MergeRequests::UpdateReviewerStateService, which fails with a swallowed "Reviewer not found" because an author is never auto-assigned as a reviewer of their own merge request. The drafts were published, but the review state was never set and no diagnostic was shown. An author who is already a reviewer on their own MR is unaffected: the state is applied.

This MR detects the case client-side: after a successful publish with --reviewer-state, it does a best-effort CurrentUser lookup and, if the user authored the MR and is not in its reviewers list, prints a warning to stderr:

! GitLab did not set your review state: you authored this merge request and are not one of its reviewers.

Publishing itself still succeeds, the field is still sent, and the exit code is unchanged. On a CurrentUser lookup error the warning is skipped (logged with GLAB_DEBUG), so the extra call can never fail the publish. The reviewers list comes from the MR already fetched by MRFromArgs, so there is no extra request for it. The --reviewer-state paragraph in the command's Long help documents when GitLab ignores the flag.

Resolves #8564 (closed)

How has this been tested?

  • Reproduced the issue end-to-end against a GDK instance (gdk.test:3000): publish as the MR author with --reviewer-state reviewed returned exit 0 with no warning, and the /reviewers readback stayed [].
  • After the fix, the same flow emits the warning on stderr while stdout/exit code are unchanged; a bare mr note publish produces no stderr output; publishing with --reviewer-state as a non-author emits no warning.
  • Unit subtests in mr_note_publish_test.go: author who is not a reviewer warns; author who is also a reviewer, non-author, and failed CurrentUser lookup do not warn. All four assert ReviewerState is still sent. A failed publish makes no CurrentUser call and prints no warning. The existing bare-publish subtest sets no CurrentUser expectation, proving no extra API call without the flag.
  • docs/source/mr/note/publish.md regenerated with make gen-docs.
Edited by Andrei Zubov

Merge request reports

Loading
Loading