Bot should request itself as reviewer before posting #35

Closed
opened 2026-05-02 17:39:27 +00:00 by rodin · 0 comments
Owner

Problem

The bot posts reviews via the API, but never adds itself as a requested reviewer on the PR. This means:

  • The Reviewers sidebar shows "no reviewers" even though reviews exist
  • Branch protection required-reviewer rules only fire if the user is in the approvals whitelist
  • Users have to manually configure branch protection to see bot reviews in the sidebar

The bot should work out of the box without any branch protection setup.

Fix

Before posting a review, the bot should call:

POST /repos/{owner}/{repo}/pulls/{number}/requested_reviewers
{"reviewers": ["<own-username>"]}

This ensures the bot always appears in the Reviewers sidebar. When the review is subsequently posted, Gitea will show the approval/rejection status there.

Implementation

  1. Add RequestReviewer(ctx, owner, repo, number, username) to gitea/client.go
  2. The bot needs to know its own username. Either:
    • Fetch via GET /user with its token (one extra API call, but self-discovering)
    • Accept a --reviewer-name flag (explicit, no extra call)
    • Parse it from the token's user (if the API exposes that)
  3. Call RequestReviewer before PostReview in the main flow
  4. If the request fails (already requested, or self-request not allowed), log a warning and continue — it's not fatal

Acceptance criteria

  • Bot appears in Reviewers sidebar without any branch protection config
  • Works on fresh repos with no setup beyond the workflow file
  • Graceful degradation if the API call fails (log warning, still post review)
  • No extra flag required — bot discovers its own username via GET /user
## Problem The bot posts reviews via the API, but never adds itself as a *requested reviewer* on the PR. This means: - The Reviewers sidebar shows "no reviewers" even though reviews exist - Branch protection required-reviewer rules only fire if the user is in the approvals whitelist - Users have to manually configure branch protection to see bot reviews in the sidebar The bot should work out of the box without any branch protection setup. ## Fix Before posting a review, the bot should call: ``` POST /repos/{owner}/{repo}/pulls/{number}/requested_reviewers {"reviewers": ["<own-username>"]} ``` This ensures the bot always appears in the Reviewers sidebar. When the review is subsequently posted, Gitea will show the approval/rejection status there. ## Implementation 1. Add `RequestReviewer(ctx, owner, repo, number, username)` to `gitea/client.go` 2. The bot needs to know its own username. Either: - Fetch via `GET /user` with its token (one extra API call, but self-discovering) - Accept a `--reviewer-name` flag (explicit, no extra call) - Parse it from the token's user (if the API exposes that) 3. Call `RequestReviewer` before `PostReview` in the main flow 4. If the request fails (already requested, or self-request not allowed), log a warning and continue — it's not fatal ## Acceptance criteria - [ ] Bot appears in Reviewers sidebar without any branch protection config - [ ] Works on fresh repos with no setup beyond the workflow file - [ ] Graceful degradation if the API call fails (log warning, still post review) - [ ] No extra flag required — bot discovers its own username via `GET /user`
rodin closed this issue 2026-05-02 19:11:16 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: rodin/review-bot#35