Skip to content

Improve failure issue for patch apply failures (merge conflicts) in create_pull_request / push_to_pull_request_branch#20421

Open
Copilot wants to merge 1 commit intomainfrom
copilot/add-fallback-issue-on-merge-conflict
Open

Improve failure issue for patch apply failures (merge conflicts) in create_pull_request / push_to_pull_request_branch#20421
Copilot wants to merge 1 commit intomainfrom
copilot/add-fallback-issue-on-merge-conflict

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

When git am fails to apply a patch (typically a merge conflict), the failure issue showed a generic "Code Push Failed" message with no recovery path. Users had no instructions for manually retrieving and applying the agent's changes.

Changes

  • handle_agent_failure.cjs: Added patchApplyErrors as a distinct error category in buildCodePushFailureContext, detected by matching "Failed to apply patch" — the error both create_pull_request and push_to_pull_request_branch return on git am failure. Added a 🔀 Patch Apply Failed section with a merge-conflict explanation and step-by-step shell instructions to download the patch artifact and apply it manually. Threads runUrl through as a new 3rd parameter so the exact run ID is embedded in the gh run download command.

  • handle_agent_failure.test.cjs: 8 new tests covering detection, PR link inclusion, instructions with/without runUrl, and mixed-error scenarios.

Example output (new section in failure issue)

🔀 Patch Apply Failed: The patch could not be applied to the current state of the repository. This is typically caused by a merge conflict between the agent's changes and recent commits on the target branch.

Failed Operations:

  • create_pull_request: Failed to apply patch

To manually apply the patch:

# Download the patch artifact from the workflow run
gh run download 22926289615 -n agent-artifacts -D /tmp/agent-artifacts-22926289615

# List available patches
ls /tmp/agent-artifacts-22926289615/*.patch

# Create a new branch (adjust as needed)
git checkout -b aw/manual-apply

# Apply the patch (--3way handles cross-repo patches)
git am --3way /tmp/agent-artifacts-22926289615/YOUR_PATCH_FILE.patch

# Push and create a pull request
git push origin aw/manual-apply
gh pr create --base main --head aw/manual-apply

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha /tmp/go-build2295522419/b422/styles.test -importcfg /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -s -w -buildmode=exe /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet -uns�� -unreachable=false /tmp/go-build2295522419/b110/vet.cfg /usr/bin/git */*.ts' '**/*.jsgit lan for patch aprev-parse x_amd64/vet git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha -unreachable=false /tmp/go-build2295522419/b117/vet.cfg 5522419/b388/vet.cfg w/js/**/*.json' git andle_agent_failrev-parse sh /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linu--json -uns�� -unreachable=false /tmp/go-build2295522419/b228/vet.cfg ache/node/24.14.0/x64/bin/node orter=verbose (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha g_.a (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel -tests /usr/bin/git set-url origin x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git --noprofile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git heck '**/*.cjs' git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha a820/Vgx0-6pZlp38hwO9a820 config /usr/bin/git remote.origin.urgit (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git 2486898191/.githgit .cfg 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/vet /usr/bin/git ck '**/*.cjs' '*git o 64/pkg/tool/linu--show-toplevel git (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha ./../pkg/workflow/js/**/*.json' --ignore-path (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha ./../pkg/workflo-errorsas (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha k/gh-aw/gh-aw/pkg/stringutil/ansi.go k/gh-aw/gh-aw/pkg/stringutil/identifiers.go /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/compile (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha /tmp/gh-aw-test-runs/20260310-223602-15155/test-3465071835/.github/workflows rev-parse /tmp/go-build2295522419/b416/sliceutil.test (http block)
  • https://api.github.com/repos/actions/upload-artifact/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/upload-artifact/git/ref/tags/v4 --jq .object.sha 580709143/001 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 -v x_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 zation_test.go x_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 -v 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 -v 64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 -v x_amd64/link (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 -v x_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path (http block)
  • https://api.github.com/repos/github/gh-aw/contents/.github%2Fworkflows%2Faudit-workflows.md
    • Triggering command: /opt/hostedtoolcache/node/24.14.0/x64/bin/node /opt/hostedtoolcache/node/24.14.0/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/gh-aw/gh-aw/actions/setup/js/node_modules/vitest/dist/workers/forks.js git cal/bin/git git form�� origin/auth-cleanup-success..auth-cleanup-success --stdout ndor/bin/git /git git k/_temp/ghcca-no--verify git (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha --noprofile (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha get --global ndor/bin/sh http.https://git/opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha get --global /home/REDACTED/.config/composer/ve--ignore-path http.https://git/opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha get --global 0/x64/bin/npx http.https://git/opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha get --global tions/setup/node_modules/.bin/no--ignore-path http.https://git/opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha get --global ache/uv/0.10.9/x86_64/git http.https://git/opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha tmatter-with-arrays.md (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion --detach (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo ache/uv/0.10.9/x-lang=go1.16 (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo ode_modules/.bin-lang=go1.17 (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build2295522419/b383/cli.test /tmp/go-build2295522419/b383/cli.test -test.testlogfile=/tmp/go-build2295522419/b383/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name (http block)

If you need me to access, download, or install something from one of these locations, you can either:


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.



✨ PR Review Safe Output Test - Run 22931244277

💥 [THE END] — Illustrated by Smoke Claude ·

Copilot AI changed the title [WIP] Add fallback issue creation for merge conflict failures Improve failure issue for patch apply failures (merge conflicts) in create_pull_request / push_to_pull_request_branch Mar 10, 2026
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💥 Automated smoke test review - all systems nominal!

💥 [THE END] — Illustrated by Smoke Claude

GH_AW_PHASE: agent
GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
GH_AW_VERSION: f11a70f
GH_AW_VERSION: f577008
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version bump looks good — f577008 is the new commit SHA for the GH_AW_VERSION env var. Automated smoke test review comment #1.

GH_AW_PROMPT: /tmp/gh-aw/aw-prompts/prompt.txt
GH_AW_SAFE_OUTPUTS: ${{ env.GH_AW_SAFE_OUTPUTS }}
GH_AW_VERSION: f11a70f
GH_AW_VERSION: f577008
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Version update confirmed for agent-performance-analyzer workflow. Both agent and detection phases updated to the same version. Automated smoke test review comment #2.

…reate_pull_request / push_to_pull_request_branch
@dsyme dsyme force-pushed the copilot/add-fallback-issue-on-merge-conflict branch from 7e91dbe to 645191c Compare March 11, 2026 02:01
@dsyme dsyme marked this pull request as ready for review March 11, 2026 02:02
Copilot AI review requested due to automatic review settings March 11, 2026 02:02
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves failure reporting for git am patch-apply failures (typically merge conflicts) during create_pull_request / push_to_pull_request_branch by adding a dedicated error category and remediation instructions, including optional workflow run–specific patch download commands.

Changes:

  • Add a new “Patch Apply Failed” error bucket in buildCodePushFailureContext, detected via "Failed to apply patch".
  • Render a dedicated 🔀 Patch Apply Failed section with manual recovery steps and optional run-ID-based gh run download instructions.
  • Add test coverage for detection and formatting behavior (with/without PR and run URL, plus mixed errors).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
actions/setup/js/handle_agent_failure.cjs Adds patch-apply failure categorization and a new remediation section; threads runUrl into context builder.
actions/setup/js/handle_agent_failure.test.cjs Adds tests validating the new patch-apply failure section and runUrl-dependent instructions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

context += `# git am --3way --continue\n\n`;
context += `# Push and create a pull request\n`;
context += `git push origin aw/manual-apply\n`;
context += `gh pr create --base main --head aw/manual-apply\n`;
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The manual recovery instructions hardcode --base main in the gh pr create step. Since this action can run in repos where the default/base branch is not main, the generated guidance may fail or create a PR against the wrong base. Consider either (a) using a placeholder like <base-branch> in the text, (b) omitting --base and letting gh use the repo default, or (c) deriving the base branch from available context (e.g., workflow inputs/env) and interpolating it.

Suggested change
context += `gh pr create --base main --head aw/manual-apply\n`;
context += `gh pr create --head aw/manual-apply\n`;

Copilot uses AI. Check for mistakes.
Comment on lines +432 to +433
context += `# If there are conflicts, resolve them and continue:\n`;
context += `# git am --3way --continue\n\n`;
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the conflict-resolution hint, git am --3way --continue is misleading: --3way is only relevant when initially applying the patch, while the normal follow-up command after resolving conflicts is git am --continue (and optionally git am --abort to back out). Adjusting this avoids users copy/pasting a command that may not behave as intended.

Suggested change
context += `# If there are conflicts, resolve them and continue:\n`;
context += `# git am --3way --continue\n\n`;
context += `# If there are conflicts, resolve them and continue (or abort):\n`;
context += `# git am --continue\n`;
context += `# git am --abort\n\n`;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Falied create_pull_request or push_to_pull_request_branch due to merge conflict should create better fallback issue

3 participants