Skip to content

Handle bundle ref mismatch in create_pull_request safe output#31955

Merged
pelikhan merged 6 commits into
mainfrom
copilot/fix-create-pull-request-handler
May 13, 2026
Merged

Handle bundle ref mismatch in create_pull_request safe output#31955
pelikhan merged 6 commits into
mainfrom
copilot/fix-create-pull-request-handler

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 13, 2026

Bug Fix

create_pull_request bundle apply assumed the bundle always contained refs/heads/<jsonl-branch>. When branch sanitization/salting changed the runtime branch name (or the bundle used a different internal ref), git fetch failed even though the bundle was valid.

  • What was the bug?

    The handler fetched a single expected ref from the bundle and failed hard on mismatch:

    • expected source ref from JSONL branch
    • actual source ref in bundle could differ
  • How did you fix it?

    • Kept the current fast path: fetch using the expected refs/heads/<branch> source ref.
    • Added fallback resolution on fetch failure:
      • run git bundle list-heads <bundle>
      • collect valid refs/heads/* entries
      • if exactly one branch ref exists, retry fetch using that ref
    • Improved failure diagnostics:
      • warning now includes original fetch error
      • explicit error when fallback cannot resolve exactly one branch ref
    • Updated fallback CLI guidance to use the resolved full ref expression.
  • Example

try {
  await exec.exec("git", ["fetch", bundleFilePath, `${bundleBranchRef}:refs/heads/${branchName}`]);
} catch (initialFetchError) {
  const { stdout } = await exec.getExecOutput("git", ["bundle", "list-heads", bundleFilePath]);
  const branchRefs = stdout
    .split("\n")
    .map(line => line.trim().split(/\s+/)[1] || "")
    .filter(ref => /^refs\/heads\/[A-Za-z0-9._][A-Za-z0-9._/-]*$/.test(ref));

  if (branchRefs.length === 1) {
    await exec.exec("git", ["fetch", bundleFilePath, `${branchRefs[0]}:refs/heads/${branchName}`]);
  } else {
    throw new Error(`Failed to resolve bundle branch ref from list-heads: expected exactly 1 refs/heads entry, found ${branchRefs.length}`, { cause: initialFetchError });
  }
}

Copilot AI and others added 3 commits May 13, 2026 14:16
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix create_pull_request safe output handler for branch ref mismatch Handle bundle ref mismatch in create_pull_request safe output May 13, 2026
Copilot AI requested a review from pelikhan May 13, 2026 14:27
@pelikhan pelikhan marked this pull request as ready for review May 13, 2026 14:34
Copilot AI review requested due to automatic review settings May 13, 2026 14:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes create_pull_request bundle application when the expected refs/heads/<jsonl-branch> ref is not present inside the bundle by adding a fallback that resolves the source ref via git bundle list-heads and retries the fetch.

Changes:

  • Update bundle fetch logic to retry with a resolved refs/heads/* ref from git bundle list-heads when the initial fetch fails.
  • Add a unit test covering the “bundle ref mismatch” fallback path.
  • Regenerate/update daily-architecture-diagram.lock.yml with broader workflow/runtime changes.
Show a summary per file
File Description
actions/setup/js/create_pull_request.cjs Adds fallback ref resolution using git bundle list-heads and updates user-facing fetch guidance to use the resolved full ref.
actions/setup/js/create_pull_request.test.cjs Adds a test verifying fetch retry with the single refs/heads/* ref discovered from the bundle.
.github/workflows/daily-architecture-diagram.lock.yml Large lockfile/workflow regeneration unrelated to the bundle ref fix (see inline comment).

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment on lines +105 to +114
- name: Checkout actions folder
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: github/gh-aw
sparse-checkout: |
actions
persist-credentials: false
- name: Setup Scripts
id: setup
uses: github/gh-aw-actions/setup@v0.72.1
uses: ./actions/setup
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot review all comments

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 13, 2026

@copilot review all comments

Reviewed all comments and addressed the actionable scope issue by reverting the unrelated lockfile/runtime churn in commit 8d2f01a. The PR now stays focused on the create_pull_request bundle ref mismatch fix.

@pelikhan pelikhan merged commit 4b0ba06 into main May 13, 2026
11 of 12 checks passed
@pelikhan pelikhan deleted the copilot/fix-create-pull-request-handler branch May 13, 2026 16:28
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.

create_pull_request safe output fails: bundle branch ref doesn't match JSONL-declared branch name

3 participants