Skip to content

BBC2-40 auto-apply effective default reviewers on bb pr create#16

Merged
b2l merged 1 commit into
mainfrom
b2lpowa/bbc2-40-auto-apply-effective-default-reviewers
Apr 15, 2026
Merged

BBC2-40 auto-apply effective default reviewers on bb pr create#16
b2l merged 1 commit into
mainfrom
b2lpowa/bbc2-40-auto-apply-effective-default-reviewers

Conversation

@b2l
Copy link
Copy Markdown
Owner

@b2l b2l commented Apr 15, 2026

Summary

Bitbucket's POST /pullrequests does not honor the repo's Default reviewers configuration. PRs created via bb pr create (or any API client) currently ship with zero reviewers, regardless of what the web UI shows under Repository settings → Default reviewers.

This PR fixes that by mimicking the web UI's behavior:

  1. Fetch GET /effective-default-reviewers (includes project-inherited defaults).
  2. Filter out the authenticated user (Bitbucket rejects a PR body where the author is also a reviewer).
  3. Inline the remaining UUIDs in the POST body as reviewers: [{type: "account", uuid}].

The two pre-create fetches (current user + default reviewers) run in parallel.

Design choices, called out

  • No opt-out flag (no --no-default-reviewers). Per the ticket, deliberate.
  • Failures propagate. If effective-default-reviewers 4xx/5xx's, we abort the create. The whole point is to stop silently shipping reviewerless PRs.
  • Single page, pagelen not bumped. Real-world default-reviewer lists are tiny (your screenshot showed 4). If anyone ever configures more, we'll add pagination.

Test plan

  • On a repo with default reviewers configured (your lcdp-front-mono per the screenshot is a good fit), run bun src/index.ts pr create --title "test: defaults" from a feature branch. Verify the resulting PR has the expected reviewers attached, matching what the web UI shows under Default reviewers (minus you if you're listed).
  • On a repo with NO default reviewers, the command still succeeds — just creates a reviewerless PR (legacy behavior preserved when nothing is configured).
  • If you happen to be in the default reviewers list yourself, confirm you're filtered out (no error, just absent).
  • Tests: bun test (145 passing, 7 new — 4 for listEffectiveDefaultReviewers, 3 for createPullRequest's reviewer-handling).
  • Lint: bun run lint.

Notes on follow-ups

BBC2-43 (in backlog) adds an explicit --reviewer <handle> flag with nickname → UUID resolution, and will switch off the default-reviewers fetch when explicit reviewers are supplied. This PR establishes the "auto-apply repo default" pattern that BBC2-15 (merge) is also told to mirror.

Bitbucket's POST /pullrequests does not honor the repo's Default
reviewers configuration; PRs created via the API ship with zero
reviewers regardless of what the web UI shows. To match the web UI's
behavior, bb pr create now reads /effective-default-reviewers (which
includes project-inherited entries) and inlines the UUIDs in the POST
body, minus the authenticated user (Bitbucket rejects a body where
the author is also a reviewer).

The default-reviewers fetch and the current-user fetch run in
parallel. Failures on either MUST propagate — we never silently
create a reviewerless PR; that's the bug we're fixing.

No opt-out flag. Explicit per ticket: users who don't want the
defaults can remove them in the web UI after the fact.

See docs/bb-notes.md → Default reviewers for the API details that
informed this.
@b2l b2l merged commit 153f0af into main Apr 15, 2026
1 check passed
@b2l b2l deleted the b2lpowa/bbc2-40-auto-apply-effective-default-reviewers branch April 15, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant