gh-aw icon indicating copy to clipboard operation
gh-aw copied to clipboard

push_to_pull_request_branch: extend #61646's transient workflows-scope-timeout retry to the primary push path

Open ekbritecore opened this issue 2 months ago • 0 comments

Title

push_to_pull_request_branch: extend #61646's transient workflows-scope-timeout retry to the primary push path

Body

Analysis

#61646 (fixed in #62486) added retry handling for create_pull_request's initial branch push on the transient GitHub error:

Unable to determine if workflow can be created or updated due to timeout;
`workflows` scope may be required.

That fix, and #48900 before it (update_pull_request.cjs), both cover their own call sites. push_to_pull_request_branch.cjs's primary push (pushSignedCommits, which is what signed-commits: false resolves to -- a real git push, the path most callers actually hit) still has zero retry and zero classification for this exact error. This was raised as a comment on #61646 itself before it was fixed, but the merged PR (#62486) only touched create_pull_request.cjs/create_pull_request_helpers.cjs/ error_recovery.cjs/update_pull_request.cjs -- push_to_pull_request_ branch.cjs was never modified.

isWorkflowsScopeRejection already exists in this same file and is applied to two other paths (the review-branch push and the fallback-branch push) -- just not to pushSignedCommits, the one most callers hit.

Slightly worse than create_pull_request's original gap in one respect: for a plain (non-fast-forward) push failure, this handler produces no fallback issue and no fallback PR at all -- fallback-as-pull-request only fires when isNonFastForward is true. A transient timeout here just returns a hard { success: false, error_type: "push_failed" } with nothing left behind for a caller to recover from.

Reproduction

Hit for real building an agentic bugfix-loop on top of push_to_pull_request_branch (engine: copilot, self-hosted runners, target: "*", signed-commits: false): the primary push failed with this exact message, no retry attempted, no fallback artifact produced. Working downstream recovery in place: poll the target PR's HEAD commit, and if it hasn't moved after a bounded wait, re-push from the agent's own bundle artifact -- confirms the failure mode is real and reproducible, not hypothetical.

Implementation Plan

Same shape as #62486, and arguably smaller since the classifier already exists in this file:

  1. Apply isWorkflowsScopeRejection (already defined in push_to_pull_request_branch.cjs) to the primary pushSignedCommits catch block, not just the review-branch/fallback-branch paths.
  2. Wrap that push in the same withRetry/RATE_LIMIT_RETRY_CONFIG (or withTransientPushRetry, if #62486 introduced a shared helper worth reusing here) pattern already used elsewhere in this file.
  3. Add a test mirroring the existing review-branch/fallback-branch coverage for this error message, but against pushSignedCommits specifically: fails once transiently then succeeds -> real push, no fallback issue; fails persistently -> falls back to whatever recovery path this file supports after retries are exhausted (or, if none exists today for this path, that's a related second gap worth its own fix -- see note above about the missing fallback for non-fast-forward failures).

Acceptance Criteria

  • A push_to_pull_request_branch push that fails once with the workflows-scope-timeout message and succeeds on retry results in a real push, not { success: false, error_type: "push_failed" }.
  • A push that fails persistently with that message still produces a clear, actionable failure (ideally with a fallback artifact, matching create_pull_request's behavior) after a bounded number of retries.

ekbritecore avatar Sep 22 '26 14:09 ekbritecore