Skip to content

fix(bitbucket): a fork's pull request from a same-named branch no longer hides the branch's own - #29751

Open
saphid wants to merge 1 commit into
pingdotgg:mainfrom
saphid:fix/bitbucket-fork-branch-pr-lookup
Open

saphid wants to merge 1 commit into
pingdotgg:mainfrom
saphid:fix/bitbucket-fork-branch-pr-lookup

Conversation

@saphid

@saphid saphid commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Problem

On a Bitbucket repository, a branch's own open pull request can go missing when a fork has an open pull request from a branch with the same name, such as main, develop or fix-typo, and that fork's pull request was updated more recently. Status then shows no pull request for the branch and offers to create one.

The branch lookup asks the provider for one open pull request per head selector, then drops rows that come from another owner. Bitbucket's listing matches source.branch.name in every fork, ignores the selector's owner, and returns the most recently updated match. So the fork's pull request takes the single slot, GitManager rejects it, and the branch's own pull request is never read.

Change

Bitbucket gets a headBranchProbe, the same as GitHub's. It drops owner:branch selectors, because Bitbucket ignores the owner and they repeat the bare-branch query. It also reads 50 rows, Bitbucket's maximum page size, which BitbucketApi already clamps to. GitManager always includes the bare head branch among the selectors and still checks owners itself, as the headBranchProbe contract describes ("The caller verifies owners, so hosts may drop unsupported owner:branch selectors"). Each lookup still sends one request per selector, and now fewer selectors are queried.

Scope and approval

Very small, focused fix for an obvious bug, so no prior issue: one provider adopts an existing hook in the way its GitHub sibling already does, for a lookup that returns the wrong answer today. 5 non-test lines.

Overlap search: the closest PR is #27890 (closed, GitCafe), which hit the same "fork pull request takes the limit-1 slot" problem and gave GitCafe a probe; it wasn't merged and didn't touch Bitbucket. #17617 introduced headBranchProbe for GitHub only. No open PR changes Bitbucket's branch lookup. Forgejo, GitLab, Azure DevOps and GitCafe have the same limit-1 exposure, but each needs its own decision (Forgejo, for example, pages until it fills the limit), so they're left out of this PR.

Verification

  • New BitbucketSourceControlProvider.test.ts case fails on main: AssertionError: expected undefined to deeply equal { headSelectors: [ 'feature' ], limit: 50 }. It passes with the fix.
  • vp test run src/server/ in packages/source-control-bitbucket: 6 files, 93 tests pass.
  • vp run check:changed: format, lint, knip, typecheck (11 packages) and tests pass.
  • Not checked: no live Bitbucket workspace with a forked pull request was available. The behavior follows from the listing query (source.branch.name plus sort=-updated_on, pagelen=min(limit, 50)) and from GitManager's owner check.

Reviewed with sol-loop: 1 round with GPT-6.1 Sol on high. Sol verdict: approved.

Created with Claude Opus 5.5 in Claude Code (T3 Code).

🤖 Generated with Claude Code

…ger hides the branch's own

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 3, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 10717d2

Macroscope's review found this PR approvable — Bitbucket branch lookups now examine up to 50 pull requests using supported branch selectors, while retaining existing repository and owner filtering. The change is limited to discovery and introduces no material operational or data risk.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 5b9731c and 10717d2.

Files selected for processing: 2
  • packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.test.ts
  • packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Walkthrough

The Bitbucket provider now filters head-branch probe selectors that contain : and sets the probe limit to 50. A test checks the returned selectors and limit.

Changes: Bitbucket head-branch probe

Layer / File(s) Summary
Add and test probe options
packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.ts, packages/source-control-bitbucket/src/server/BitbucketSourceControlProvider.test.ts
The provider excludes selectors containing : and sets the probe limit to 50. The test checks the returned selectors and limit.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix

Possibly related issues

Possibly related PRs

  • pingdotgg/t3code#13200: This PR applies a related lookup strategy for GitHub by removing unsupported selectors and increasing the query limit.
  • pingdotgg/t3code#27890: This PR addresses branch collisions on GitCafe and increases the head-branch probe limit.

Suggested labels: size:XS

Suggested reviewers: juliusmarminge, macroscopeapp

Merge Risk: Minimal · up to 10717

The probe change has focused regression coverage, with no remaining merge-blocking risk identified.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title clearly and concisely describes the Bitbucket fix for same-named fork branches hiding the repository's own pull request.
Description check Passed The description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the failure mode, implementation, scope rationale, focused test results, broader checks, a…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description includes complete Problem, Change, Scope and approval, and Verification sections. It explains the failure mode, implementation, scope rationale, focused test results, broader checks, and the unavailable live Bitbucket verification.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant