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
- Move
git push origin ${branchName} and the commit-count logic outside the patch try/catch block.
- 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.
- 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
Objective
Separate the
git pushfrom the patchtry/catchblock inpush_to_pull_request_branch.cjsso 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 pushcan fail with non-fast-forward errors when multiple agents update the same branch. Currently, the push is inside the sametry/catchasgit 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–418Approach
git push origin ${branchName}and the commit-count logic outside the patchtry/catchblock.{ success: false, error_type: "push_failed", error: "Failed to push changes: ..." }"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.""Failed to push changes: (original error)"message.try/catchonly — do not run it for push failures.Files to Modify
actions/setup/js/push_to_pull_request_branch.cjsAcceptance Criteria
git pushfailure no longer produces the message "Failed to apply patch"git ampatch failure still produces "Failed to apply patch" with the patch investigation outputmake fmt-cjsandmake lint-cjsafter the changeRelated to create_pull_request / push_to_pull_request_branch: push failure misattributed as patch failure + fallback issues missing agentic-workflows label #18980