-
Notifications
You must be signed in to change notification settings - Fork 251
Description
Note
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.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)- The
safe_outputsjob checks out the target repo (where the file already exists) and runsgit 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: mainSuggested 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- Copilot CLI: 0.0.411
- Model: claude-opus-4.6