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.
Related Issues
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 reviewedreturned exit 0 with no warning, and the/reviewersreadback stayed[]. - After the fix, the same flow emits the warning on stderr while stdout/exit code are unchanged; a bare
mr note publishproduces no stderr output; publishing with--reviewer-stateas 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 failedCurrentUserlookup do not warn. All four assertReviewerStateis still sent. A failed publish makes noCurrentUsercall and prints no warning. The existing bare-publish subtest sets noCurrentUserexpectation, proving no extra API call without the flag. docs/source/mr/note/publish.mdregenerated withmake gen-docs.