Skip to content

Recover complex create_pull_request bundle application when signed push rejects merge topology#32405

Merged
pelikhan merged 2 commits into
mainfrom
copilot/fix-complex-create-pull-request-changes-again
May 15, 2026
Merged

Recover complex create_pull_request bundle application when signed push rejects merge topology#32405
pelikhan merged 2 commits into
mainfrom
copilot/fix-complex-create-pull-request-changes-again

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 15, 2026

Bug Fix

Complex create_pull_request bundle payloads (including merge topology) were being applied locally but failing at signed push replay (pushSignedCommits), which forced fallback issue creation instead of opening a PR in cases like the referenced chaos run. This change adds an in-flow recovery so complex bundle changes still land as PR branches under signed-commit constraints.

  • What was the bug?

    Bundle transport preserved merge commit topology, but signed replay via createCommitOnBranch rejects merge commits. In that path, create_pull_request treated the push as terminal and fell back to an issue, even when the net file changes were otherwise valid for PR creation.

  • How did you fix it?

    Added a targeted recovery path in the bundle push flow:

    • detect signed-push refusal specifically for merge-commit topology
    • rewrite the branch to a single linear commit relative to origin/<base>
    • retry pushSignedCommits using the rewritten history
    • keep existing fallback-to-issue behavior only if rewrite/retry also fails
  • Implementation notes

    Recovery is scoped to the bundle + signed-commit merge-refusal case and does not alter normal patch flow or non-merge failures. The retry path preserves the branch target and continues through standard PR creation once push succeeds.

try {
  await pushSignedCommits({ branch, baseRef: `origin/${baseBranch}`, signedCommits: true });
} catch (err) {
  if (isSignedMergeReplayRefusal(err)) {
    await rewriteBundleBranchAsSingleCommit(baseBranch, exec);
    await pushSignedCommits({ branch, baseRef: `origin/${baseBranch}`, signedCommits: true });
  } else {
    throw err;
  }
}

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Fix complex create_pull_request bundle application for signed pushes Recover complex create_pull_request bundle application when signed push rejects merge topology May 15, 2026
Copilot AI requested a review from pelikhan May 15, 2026 14:50
@pelikhan pelikhan marked this pull request as ready for review May 15, 2026 14:58
Copilot AI review requested due to automatic review settings May 15, 2026 14:58
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

Adds an in-flow recovery path so that bundle-transported PR branches whose history contains merge commits are not lost when signed-commit replay refuses to push them. When pushSignedCommits rejects a merge-commit topology, the branch is soft-reset to origin/<base> and recommitted as a single linear commit, then the signed push is retried; the existing fallback-to-issue behavior is preserved only if the retry also fails.

Changes:

  • New helper rewriteBundleBranchAsSingleCommit that soft-resets to the base ref, asserts staged changes exist, recommits with a derived headline, and rolls back to the original HEAD on failure.
  • Push-error handler now detects the specific signed-merge-replay refusal (signedCommits && /refusing unsigned push/ && /merge commit/i), invokes the rewrite, retries pushSignedCommits, recounts new commits, and only falls through to the original fallback-issue logic when the retry also fails.
  • New jest test covering the rewrite + retry path and verifying no fallback issue is created.
Show a summary per file
File Description
actions/setup/js/create_pull_request.cjs Adds the rewriteBundleBranchAsSingleCommit helper and wraps the bundle-push catch block with merge-refusal recovery, preserving existing fallback-issue behavior under an else.
actions/setup/js/create_pull_request.test.cjs Adds a unit test that mocks a signed-push merge-commit refusal followed by a successful retry, asserting the soft-reset + commit sequence and that no fallback issue is created.

Copilot's findings

Tip

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 2

Comment on lines +1518 to +1584
@@ -1494,6 +1581,7 @@ gh pr create --title '${title}' --base ${baseBranch} --head ${branchName} --repo
const error = `Failed to push changes and failed to create fallback issue. Push error: ${pushError instanceof Error ? pushError.message : String(pushError)}. Issue error: ${issueError instanceof Error ? issueError.message : String(issueError)}`;
return { success: false, error };
}
}
Comment on lines +1516 to +1518
if (pushRecovered) {
core.info("Bundle push recovered after signed-commit rewrite");
} else {
@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 15, 2026

@copilot review all comments

Done in 65e8aba. I addressed the review feedback by removing the redundant recovery-success info log and fixing the indentation/scope of the fallback block in create_pull_request.cjs, then re-ran targeted tests (create_pull_request.test.cjs) and validation.

@pelikhan pelikhan merged commit 46f04b1 into main May 15, 2026
@pelikhan pelikhan deleted the copilot/fix-complex-create-pull-request-changes-again branch May 15, 2026 15:41
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.

3 participants