fix(bitbucket): send reviewer user.name instead of user.slug - #462
Conversation
Bitbucket Server rejects pull request create/update requests when reviewers[].user.slug is sent instead of reviewers[].user.name, which is the field the Data Center API actually reads for identifying a reviewer by username. Closes #461 Co-authored-by: imagile-bot[bot] <310767887+imagile-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Small, well-scoped fix: brings createPR/updatePR reviewer serialization in line with addReviewer's existing correct user.name shape for Bitbucket Data Center. Verified the surviving 'slug' references elsewhere in client.ts are unrelated (repo slug, participants URL path). New tests follow existing conventions and cover both single/multiple reviewers. No breaking change — reviewers field always held usernames.
There was a problem hiding this comment.
Small, well-scoped fix: brings createPR/updatePR reviewer serialization in line with addReviewer's existing correct user.name shape for Bitbucket Data Center's /rest/api/1.0 reviewer bodies. Verified the surviving slug references elsewhere in client.ts are unrelated (repo slug in fromRef/toRef, and the /participants/{userSlug} path segment in needsWorkPR, which is the correct field for that endpoint). New tests follow the existing addReviewer test pattern and cover both single and multiple reviewers. No breaking change — the reviewers field on CreatePROpts/UpdatePROpts always held usernames per the --reviewers help text, only the internal request-body key changes.
No bugs, security issues, or pattern deviations found.
|
Claude finished @kolatts's task in 1m 34s —— View job Reviewing PR #462
SummarySmall, well-scoped fix. Correctness: Verified every other
Types/back-compat: Tests: The two new tests in No bugs, security issues, or pattern deviations found. Review submitted: ✅ Approved via Process note
|
Superseded by a newer automated review
There was a problem hiding this comment.
Small, well-scoped fix. createPR and updatePR (src/services/bitbucket/client.ts:114, :124) were serializing reviewers as { user: { slug } }, but Bitbucket Server's Data Center REST API (/rest/api/1.0) identifies a user by name (the username), not slug. addReviewer (client.ts:337) already used the correct { user: { name } } shape — this brings the two other call sites in line, matching the repo's Deployment Variant — Target Self-Hosted convention (same precedent as Jira's name-vs-accountId split).
Correctness: Verified every other slug reference in client.ts is unrelated and correctly left alone:
client.ts:103,110—opts.repoas a repository slug infromRef/toRef, a different field.client.ts:315—r.user.slug === currentUser.slugidentity comparison inneedsWorkPR.client.ts:324—/participants/{userSlug}URL path segment, which Bitbucket Server's API documents asuserSlug.
Types/back-compat: reviewers?: string[] on CreatePROpts/UpdatePROpts was always meant to hold usernames — the --reviewers <users> CLI help text already says "usernames" (commands.ts:98,120,181). Only the internal request-body key changes; no public type, flag, or JSON envelope field is renamed, so this isn't a breaking change under CLAUDE.md's "Changing Existing Behavior" rules.
Tests: The two new tests in client.test.ts follow the existing addReviewer test pattern (vi.stubGlobal('fetch', ...) capturing { url, method, body }), asserting the fixed shape ({ user: { name: 'jsmith' } }) for both createPR (multiple reviewers) and updatePR (single reviewer), per the repo's Testing Rule (no live network dependency).
No bugs, security issues, or pattern deviations found.
Summary
Bitbucket Server pull request create/update requests serialized reviewers as
reviewers[].user.slug, but the Data Center REST API identifies a user byreviewers[].user.name(the username). Bitbucket Server rejects the request whenslugis sent instead, sopncli bitbucket create-pr --reviewersandpncli bitbucket update-pr --reviewersfailed.addRevieweralready used the correctuser.nameshape — this bringscreatePRandupdatePRin line with it.Changes
src/services/bitbucket/client.ts:createPRandupdatePRnow serialize each reviewer as{ user: { name } }instead of{ user: { slug } }.src/services/bitbucket/client.test.ts: added coverage assertingcreatePR/updatePRsenduser.namein the request body.Testing
npm run typecheck— passnpm run lint— passnpm test— pass (639 tests)Closes #461
Generated with Claude Code