Skip to content

[plan] Fix push failure misattributed as "Failed to apply patch" in push_to_pull_request_branch.cjs #18984

@github-actions

Description

@github-actions

Objective

Separate the git push from the patch try/catch block in push_to_pull_request_branch.cjs so that push failures are reported with accurate, actionable error messages rather than being misattributed as patch failures.

Context

Reported in issue #18980. In concurrent agentic pipelines, git push can fail with non-fast-forward errors when multiple agents update the same branch. Currently, the push is inside the same try/catch as git am --3way, so a push failure returns { success: false, error: "Failed to apply patch" } — a misleading error that triggers expensive patch investigations instead of a simple re-run.

Location

actions/setup/js/push_to_pull_request_branch.cjs — around lines 369–418

Approach

  1. Move git push origin ${branchName} and the commit-count logic outside the patch try/catch block.
  2. Add a dedicated push error handler after the patch block that:
    • Returns a distinct error result, e.g. { success: false, error_type: "push_failed", error: "Failed to push changes: ..." }
    • Detects non-fast-forward patterns in the error message and returns actionable messaging: "Failed to push changes: remote PR branch changed while the workflow was running (non-fast-forward). Re-run the workflow on the latest PR branch state."
    • For other push errors, returns a generic "Failed to push changes: (original error)" message.
  3. Keep the patch investigation logic (git status, log, diff, am --show-current-patch) inside the patch try/catch only — do not run it for push failures.

Files to Modify

  • actions/setup/js/push_to_pull_request_branch.cjs

Acceptance Criteria

Generated by Plan Command for issue #18980

  • expires on Mar 3, 2026, 4:46 AM UTC

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions