Skip to content

fix: av stack submit incorrectly picks base branch - #794

Open
Roshan931 wants to merge 1 commit into
aviator-co:masterfrom
Roshan931:prilog/fix-error-stale-refs-remotes-origin-head-yields-a-09-29-2026-764d28
Open

Roshan931 wants to merge 1 commit into
aviator-co:masterfrom
Roshan931:prilog/fix-error-stale-refs-remotes-origin-head-yields-a-09-29-2026-764d28

Conversation

@Roshan931

@Roshan931 Roshan931 commented Sep 29, 2026 •

Copy link
Copy Markdown

Fixes #77

Root cause

Stale refs/remotes/origin/HEAD yields a nonexistent default branch

Changes

  • Validate the remote HEAD symbolic ref in git.OpenRepo: require it to point at a refs/remotes// branch and require that target ref to resolve. Otherwise fail early with an actionable message suggesting git remote set-head --auto <remote>, instead of deriving a bogus default branch. Added a regression test that points refs/remotes/origin/HEAD at a nonexistent branch and asserts OpenRepo errors.

Summary by CodeRabbit

  • Bug Fixes
    • Repository opening now checks that the configured remote’s default branch reference points to an existing remote branch. If the reference is missing, invalid, or stale, opening the repository returns an error instead of selecting an invalid default branch.
    • Warnings now identify the configured remote when its HEAD needs to be set; missing-reference warnings continue to recommend setting origin’s HEAD.

@Roshan931
Roshan931 requested a review from a team as a code owner September 29, 2026 21:16
@aviator-app

aviator-app Bot commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Current Aviator status

Aviator will automatically update this comment as the status of the PR changes.
Comment /aviator refresh to force Aviator to re-examine your PR (or learn about other /aviator commands).

This pull request is currently open (not queued).

How to merge

To merge this PR, comment /aviator merge or add the mergequeue label.


See the real-time status of this PR on the Aviator webapp.
Use the Aviator Chrome Extension to see the status of your PR within GitHub.

@aviator-app

aviator-app Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

🔃 FlexReview Status

Common Owner: aviator-co/engineering (expert-load-balance assignment)
Owner and Assignment:

  • 🔒 aviator-co/engineering (expert-load-balance assignment)
    Owned Files
    • 🔒 internal/git/git.go
    • 🔒 internal/git/git_test.go

Review SLO: 7 business hours if PR size is <= 200 LOC for the first response.

@aviator-app
aviator-app Bot requested a review from simsinght September 29, 2026 21:16
@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: e3752d68-638f-41ad-b4a6-51c7ed3a1a83

📥 Commits

Reviewing files that changed from the base of the PR and between 6a11f1e and b851aca.

📒 Files selected for processing (2)
  • internal/git/git.go
  • internal/git/git_test.go

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


📝 Walkthrough

Walkthrough

OpenRepo now validates the configured remote’s symbolic HEAD before setting the default branch. It returns an error if the target is outside the remote’s tracking refs or if the target branch does not exist. A new test checks the stale-reference error.

Changes

Remote HEAD validation

Layer / File(s) Summary
Validate remote HEAD target
internal/git/git.go, internal/git/git_test.go
OpenRepo checks that the remote HEAD targets an existing remote-tracking branch before storing its branch name. The test verifies that a stale origin/HEAD target returns an error containing the reference path.

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: jainankit, tulioz

Merge Risk: ⚪ Minimal · up to b851a

Opening a repository with a stale remote HEAD now fails early with a clear error instead of picking a nonexistent default branch. No merge-blocking risk was identified. This does not make submission use the correct base branch as issue #77 asks; it only rejects the invalid state early.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #77 requires av stack submit to use the correct existing base branch, such as main, instead of master. The PR changes OpenRepo to reject a remote HEAD that targets a missing branch and… Change default-branch resolution so av stack submit can select the existing correct base branch when the remote HEAD is stale, or otherwise implement an equivalent successful main base selection. Add a regression test for that behavio…
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary user-facing issue: av stack submit selecting an incorrect base branch. The changes address this issue by validating stale remote HEAD references before dete…
Out of Scope Changes check ✅ Passed The changes validate the remote HEAD used to determine the default base branch and add a regression test for a stale remote HEAD. These changes directly address the incorrect-base-branch failure i…
Full details: Linked Issues check

Explanation

Issue #77 requires av stack submit to use the correct existing base branch, such as main, instead of master. The PR changes OpenRepo to reject a remote HEAD that targets a missing branch and suggests git remote set-head --auto &lt;remote&gt;. The added test verifies the error for origin/master; it does not verify successful submission or base-branch selection for main.

Resolution

Change default-branch resolution so av stack submit can select the existing correct base branch when the remote HEAD is stale, or otherwise implement an equivalent successful main base selection. Add a regression test for that behavior.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

av stack submit incorrectly picks base branch

1 participant