You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue was AI-generated based on investigation of two failing workflow runs.
Problem
When a workflow's target-repo differs from the source repo (cross-repo safe-output PR), git am fails with exit code 128 because the patch is generated as create mode 100644 (new file) even though the file already exists in the target repo.
Reproduction
This is reproducible in a cross-repo workflow that:
runs in a source repo workspace
reads a file from a different target repo via GitHub MCP
writes/edits that file locally
emits a patch via generate_git_patch.sh
applies the patch in the target repo via safe-outputs
In this configuration, the patch is generated as create mode 100644, but the file already exists in the target repo, so git am fails with exit code 128.
Root Cause
The agent runs in the source repo workspace
It reads a file from the target repo via GitHub MCP, writes it locally, and edits it
generate_git_patch.sh diffs against the source repo's HEAD — since the file doesn't exist in the source repo, the diff is create mode 100644 (a full new-file patch)
The safe_outputs job checks out the target repo (where the file already exists) and runs git am, which correctly rejects creating a file that already exists
Workflow config
safe-outputs:
create-pull-request:
target-repo: 'microsoft/vscode-docs'allowed-repos: ['microsoft/vscode-docs']base-branch: main
Suggested Fix
Either (or both):
Patch generation: When target-repo differs from the source repo, diff against the target repo's tree instead of the source repo's HEAD. This would produce a proper "modify existing file" patch.
Patch application: Use git am --3way (or fall back to git apply --3way) when applying cross-repo patches, which can resolve the create-vs-modify mismatch using the target repo's index.
Note
This issue was AI-generated based on investigation of two failing workflow runs.
Problem
When a workflow's
target-repodiffers from the source repo (cross-repo safe-output PR),git amfails with exit code 128 because the patch is generated ascreate mode 100644(new file) even though the file already exists in the target repo.Reproduction
This is reproducible in a cross-repo workflow that:
generate_git_patch.shIn this configuration, the patch is generated as
create mode 100644, but the file already exists in the target repo, sogit amfails with exit code 128.Root Cause
generate_git_patch.shdiffs against the source repo's HEAD — since the file doesn't exist in the source repo, the diff iscreate mode 100644(a full new-file patch)safe_outputsjob checks out the target repo (where the file already exists) and runsgit am, which correctly rejects creating a file that already existsWorkflow config
Suggested Fix
Either (or both):
Patch generation: When
target-repodiffers from the source repo, diff against the target repo's tree instead of the source repo's HEAD. This would produce a proper "modify existing file" patch.Patch application: Use
git am --3way(or fall back togit apply --3way) when applying cross-repo patches, which can resolve the create-vs-modify mismatch using the target repo's index.Environment
gh-aw: v0.46.5 / awf v0.20.1 / awmg v0.1.4