Skip to content

fix(bitbucket): send reviewer user.name instead of user.slug - #462

Merged
kolatts merged 2 commits into
mainfrom
claude/issue-461
Sep 16, 2026
Merged

kolatts merged 2 commits into
mainfrom
claude/issue-461

Conversation

@imagile-bot

@imagile-bot imagile-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Summary

Bitbucket Server pull request create/update requests serialized reviewers as reviewers[].user.slug, but the Data Center REST API identifies a user by reviewers[].user.name (the username). Bitbucket Server rejects the request when slug is sent instead, so pncli bitbucket create-pr --reviewers and pncli bitbucket update-pr --reviewers failed.

addReviewer already used the correct user.name shape — this brings createPR and updatePR in line with it.

Changes

  • src/services/bitbucket/client.ts: createPR and updatePR now serialize each reviewer as { user: { name } } instead of { user: { slug } }.
  • src/services/bitbucket/client.test.ts: added coverage asserting createPR/updatePR send user.name in the request body.

Testing

  • npm run typecheck — pass
  • npm run lint — pass
  • npm test — pass (639 tests)

Closes #461

Generated with Claude Code

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>
github-actions[bot]
github-actions Bot previously approved these changes Sep 15, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

github-actions[bot]
github-actions Bot previously approved these changes Sep 16, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

github-actions Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Claude finished @kolatts's task in 1m 34s —— View job


Reviewing PR #462

  • Clean up stale Claude feedback comments — deleted 3 stale github-actions[bot] comments and dismissed 2 prior formal reviews from github-actions[bot]
  • Gather context (diff via git diff origin/main...HEAD, changed files, CLAUDE.md rules)
  • Review code quality/correctness
  • Review CLI UX
  • Review security
  • Review bugs/edge cases
  • Check adherence to existing patterns
  • Submit formal GitHub review (approve or request changes)

Summary

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,110opts.repo as a repository slug in fromRef/toRef, a different field.
  • client.ts:315r.user.slug === currentUser.slug identity comparison in needsWorkPR.
  • client.ts:324/participants/{userSlug} URL path segment, which Bitbucket Server's API documents as userSlug.

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 bugs, security issues, or pattern deviations found.

Review submitted: ✅ Approved via mcp__github__create_and_submit_pull_request_review.

Process note

npm/npx invocations (typecheck/lint/test) require approval not available in this sandbox, so I couldn't independently re-run the gates. The change is small enough to verify by direct inspection (shown above), and the PR description states all three gates pass locally (639 tests).

@github-actions
github-actions Bot dismissed stale reviews from themself September 16, 2026 00:11

Superseded by a newer automated review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,110opts.repo as a repository slug in fromRef/toRef, a different field.
  • client.ts:315r.user.slug === currentUser.slug identity comparison in needsWorkPR.
  • client.ts:324/participants/{userSlug} URL path segment, which Bitbucket Server's API documents as userSlug.

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.

@kolatts
kolatts merged commit 8f5eb51 into main Sep 16, 2026
5 checks passed
@kolatts
kolatts deleted the claude/issue-461 branch September 16, 2026 00:29
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.

Bitbucket pull request reviewers use the wrong user property

1 participant