GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(bitbucket): use FindBranch and paginate PR listing in pullrequest… by roulettedares · Pull Request #8584 · updatecli/updatecli

Conversation

@roulettedares

@roulettedares roulettedares commented Apr 24, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Problem

isRemoteBranchesExist() and isPullRequestExist() both fetch only the first page of results (Page: 1, Size: 30) with no follow-through pagination. On repositories with more than 30 branches, if either the source branch or target branch (main)
sorts alphabetically past position 30, the function silently returns false — causing CreateAction to log "skipping pull request creation" at Debug level and exit with nil. The job appears green with no PR created and no visible explanation in
normal log output.

Root cause / history

The Stash plugin (PR #1246, March 2023) used ListBranches with a manual name-match loop. The Bitbucket Cloud plugin (PR #2847, October 2024) copy-pasted this approach verbatim; no reviewer questioned it. FindBranch has been present in both
go-scm Bitbucket drivers since 2018 and was never unavailable. Branch names are never wildcards or patterns — there was no reason to list all branches. PR #5133 silently switched to FindBranch elsewhere in a refactor, but the Bitbucket Cloud
plugin was not updated.

Fix

Replace the ListBranches scan in isRemoteBranchesExist() with two direct FindBranch calls — one per branch. This is O(1) regardless of branch count, matches the approach used by GitHub's GraphQL ref(qualifiedName:) lookup, and treats a 404
response as "branch not found" logged at Warning level so the failure is visible without --debug.

Also fix isPullRequestExist() which has the same Size: 30 truncation: it now paginates using resp.Page.Next until all open pull requests have been checked.

Relates to #1905 (same class of bug observed in GitLab). Introduced in #2847.

Test

To test this pull request, you can run the following commands:

cd <to_package_directory>
go test

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@roulettedares
fix(bitbucket): use FindBranch and paginate PR listing in pullrequest…
8c65cf6
… action

isRemoteBranchesExist() fetched all remote branches via a paginated list
scan (Page: 1, Size: 30 with no follow-through) to check whether the
source and target branches exist. On repositories with more than 30
branches this silently returned false, causing CreateAction to log
"skipping pull request creation" at Debug level and exit with nil — the
job appeared green with no PR and no visible explanation.

Replace the list scan with two direct FindBranch calls (one per branch).
This mirrors the approach used by GitHub's GraphQL implementation and is
O(1) regardless of repository branch count. A 404 response from
FindBranch is treated as a missing branch and logged at Warning level so
the failure is visible without --debug.

Also fix isPullRequestExist() which had the same Size: 30 truncation: it
now paginates using resp.Page.Next until all open pull requests have been
checked.

Fixes the same class of bug as updatecli#1905 (GitLab) which was introduced when
the Bitbucket Cloud plugin was added in updatecli#2847.
@olblak

olblak commented Apr 24, 2026

Copy link
Copy Markdown
Member

Thanks for the fix

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@olblak

olblak commented Apr 24, 2026

Copy link
Copy Markdown
Member

And thank you for the clear explanation.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@olblak olblak added bug Something isn't working scm-bitbucket All things related to the bitbucket integration labels Apr 24, 2026
@olblak

olblak commented Apr 24, 2026

Copy link
Copy Markdown
Member

@roulettedares Could you confirm that you tested this pullrequest on a bitbucket repository?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@olblak
Merge branch 'main' into fix/bitbucket-pullrequest-branch-pagination
4214775
@roulettedares

roulettedares commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

it's been consistently working on repos with more than 30 branches

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@olblak

olblak commented Apr 25, 2026

Copy link
Copy Markdown
Member

Thank you awesome, then I'll skip the manual testing this time

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@olblak
olblak merged commit 7b197e1 into updatecli:main Apr 25, 2026
7 checks passed

Uh oh!

There was an error while loading. Please reload this page.

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

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

bug Something isn't working scm-bitbucket All things related to the bitbucket integration

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@roulettedares @olblak
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.