Summary
In a maintainer-triggered PR /repo-assist (issue_comment) run against a fork PR, gh-aw successfully checks out the fork head via refs/pull/<N>/head, but push_to_pull_request_branch cannot generate its incremental patch because it requires refs/remotes/origin/<head.ref>.
Run: https://github.com/fsprojects/Paket/actions/runs/33002971793
PR: fsprojects/Paket#4323
Compiled with gh-aw v0.86.2.
Reproduction
PR #4323 is cross-repository:
- base:
fsprojects/Paket:master
- head:
nicholi/Paket:feature/native_versions
- head SHA at the run:
dbc69e77bc96a989973ec55c2a0bddfd3e8e63bf
The workflow has:
checkout:
fetch: ["*"]
fetch-depth: 0
The checkout step correctly detected the fork and fetched:
+refs/pull/4323/head:refs/remotes/origin/pr-head
It then created local branch feature/native_versions from origin/pr-head. The agent committed its change locally and made a corrected safe-output call:
safeoutputs push_to_pull_request_branch
with repo: fsprojects/Paket, pull_request_number: 4323, and branch: feature/native_versions.
The call failed synchronously:
Cannot generate incremental patch: refs/remotes/origin/feature/native_versions is not present in checkout ... Add "feature/native_versions" to the workflow's checkout.fetch list so the branch is fetched during setup.
No push_to_pull_request_branch item was persisted because MCP patch generation failed before recording the write intent. The agent subsequently emitted report_incomplete, which was the only message processed by the downstream safe_outputs job.
Root cause
actions/setup/js/checkout_pr_branch.cjs handles fork PRs by fetching the correct PR tip to origin/pr-head and checking out a local branch named from pulls.get(...).head.ref.
Incremental patch generation in actions/setup/js/generate_git_patch.cjs instead calls ensureOriginRemoteTrackingRef(branchName) and requires origin/<branchName> as its base.
For a fork PR, checkout.fetch refspecs operate on the base repository's origin. Therefore fetch: ["*"] can only fetch fsprojects/Paket branches and cannot create origin/feature/native_versions from nicholi/Paket. The current remediation text is not actionable for fork PRs.
There is also a correctness risk if the base repository happens to have a same-named branch: wildcard fetch can populate origin/<head.ref> from the wrong repository, causing incremental patch generation to use the wrong base commit.
Expected behavior
For a trusted maintainer-triggered PR-context workflow, the already-fetched refs/pull/<N>/head commit should be available as the incremental base for push_to_pull_request_branch, including when the PR comes from a fork. checkout.fetch should not need to name a fork branch.
The downstream push handler can continue using PR API metadata and its authenticated fork-aware push path; patch generation only needs an unambiguous local ref/SHA representing the PR tip before the agent's commits.
Suggested direction
Pass or persist an explicit PR-head baseline (for example the fetched origin/pr-head SHA) for incremental patch generation instead of inferring it from origin/<head.ref>. Avoid aliasing to origin/<head.ref> unless all consumers can distinguish the head repository, because that namespace normally represents the base repo remote.
Also update the error so it does not claim the safe-outputs server lacks credentials for a public fork or recommend checkout.fetch when the missing ref belongs to a fork.
Regression coverage
issue_comment /repo-assist on a fork PR, with fetch: ["*"] and fetch-depth: 0
- fork PR whose head branch does not exist in the base repo
- fork PR whose head branch name also exists in the base repo, proving the fork PR tip is used
- corrected
push_to_pull_request_branch call generates an incremental patch from the pre-agent PR tip and is persisted for downstream processing
Summary
In a maintainer-triggered PR
/repo-assist(issue_comment) run against a fork PR, gh-aw successfully checks out the fork head viarefs/pull/<N>/head, butpush_to_pull_request_branchcannot generate its incremental patch because it requiresrefs/remotes/origin/<head.ref>.Run: https://github.com/fsprojects/Paket/actions/runs/33002971793
PR: fsprojects/Paket#4323
Compiled with gh-aw v0.86.2.
Reproduction
PR #4323 is cross-repository:
fsprojects/Paket:masternicholi/Paket:feature/native_versionsdbc69e77bc96a989973ec55c2a0bddfd3e8e63bfThe workflow has:
The checkout step correctly detected the fork and fetched:
It then created local branch
feature/native_versionsfromorigin/pr-head. The agent committed its change locally and made a corrected safe-output call:with
repo: fsprojects/Paket,pull_request_number: 4323, andbranch: feature/native_versions.The call failed synchronously:
No
push_to_pull_request_branchitem was persisted because MCP patch generation failed before recording the write intent. The agent subsequently emittedreport_incomplete, which was the only message processed by the downstreamsafe_outputsjob.Root cause
actions/setup/js/checkout_pr_branch.cjshandles fork PRs by fetching the correct PR tip toorigin/pr-headand checking out a local branch named frompulls.get(...).head.ref.Incremental patch generation in
actions/setup/js/generate_git_patch.cjsinstead callsensureOriginRemoteTrackingRef(branchName)and requiresorigin/<branchName>as its base.For a fork PR,
checkout.fetchrefspecs operate on the base repository'sorigin. Thereforefetch: ["*"]can only fetchfsprojects/Paketbranches and cannot createorigin/feature/native_versionsfromnicholi/Paket. The current remediation text is not actionable for fork PRs.There is also a correctness risk if the base repository happens to have a same-named branch: wildcard fetch can populate
origin/<head.ref>from the wrong repository, causing incremental patch generation to use the wrong base commit.Expected behavior
For a trusted maintainer-triggered PR-context workflow, the already-fetched
refs/pull/<N>/headcommit should be available as the incremental base forpush_to_pull_request_branch, including when the PR comes from a fork.checkout.fetchshould not need to name a fork branch.The downstream push handler can continue using PR API metadata and its authenticated fork-aware push path; patch generation only needs an unambiguous local ref/SHA representing the PR tip before the agent's commits.
Suggested direction
Pass or persist an explicit PR-head baseline (for example the fetched
origin/pr-headSHA) for incremental patch generation instead of inferring it fromorigin/<head.ref>. Avoid aliasing toorigin/<head.ref>unless all consumers can distinguish the head repository, because that namespace normally represents the base repo remote.Also update the error so it does not claim the safe-outputs server lacks credentials for a public fork or recommend
checkout.fetchwhen the missing ref belongs to a fork.Regression coverage
issue_comment/repo-assiston a fork PR, withfetch: ["*"]andfetch-depth: 0push_to_pull_request_branchcall generates an incremental patch from the pre-agent PR tip and is persisted for downstream processing