fix: correctly list pull request branch candidates - #3711
Open
Navaneeth92 wants to merge 1 commit into
Open
Conversation
|
Navaneeth Ananthakrishnan seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
Navaneeth92
force-pushed
the
fix/pr-banner-default-branch
branch
from
August 2, 2026 08:08
a912732 to
592ea12
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
This PR fixes the PR banner candidate selection logic so that:
branchestable.Problem
The existing implementation fetched the default branch metadata from the
branchestable before querying PR banner candidates.For newly created repositories, the default branch may already exist in Git while its metadata has not yet been persisted in the
branchestable. In that situation, the endpoint:returned 404 (Not Found), preventing the UI from displaying the "Compare & Pull Request" banner.
Additionally, the previous SQL query relied on joins involving
branch_last_created_pullreq_id, which could lead to incorrect banner behaviour in certain scenarios.Root Cause
Candidate lookup depended on:
If the default branch record was missing, candidate lookup failed entirely.
The join-based query also made it difficult to reliably distinguish between:
Solution
This PR simplifies the candidate selection logic by:
NOT EXISTSquery that filters branches where:This removes the dependency on the default branch metadata while preserving the intended banner behaviour.
Testing
Verified manually using a fresh database.
Scenarios Tested
Notes
This change is intentionally scoped to the backend candidate selection logic and does not introduce any UI changes.