Skip to content

fix: Claude workflow fails on fork PRs when head branch is 'main' - #685

Merged
kovtcharov merged 1 commit into
mainfrom
fix/claude-workflow-fork-checkout
Apr 1, 2026
Merged

kovtcharov merged 1 commit into
mainfrom
fix/claude-workflow-fork-checkout

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Summary

  • Fix fatal: a branch named 'main' already exists error when reviewing fork PRs where the contributor's head branch is main (their default branch)
  • Fix corrupted diff base — after redirecting origin to the fork, origin/$BASE_BRANCH gets overwritten, so save the base SHA before any URL changes
  • Use fixed branch name pr-head with -B (force-create) instead of -b $HEAD_REF to avoid name collisions

Root Cause

When a fork PR uses main as its head branch (PR #684):

  1. actions/checkout creates local main branch from the base repo
  2. git checkout -b main origin/main fails because main already exists
  3. Even if that succeeded, git fetch origin main (from fork) would overwrite origin/main, making the diff compare fork-vs-fork instead of base-vs-fork

Failed run: https://github.com/amd/gaia/actions/runs/23859641383/job/69562473226

Test plan

  • Trigger Claude review on PR #684 (fork PR with main as head branch) — should succeed
  • Trigger Claude review on a non-fork PR — should still work as before
  • Verify the generated diff in logs shows correct base-vs-fork comparison

When a fork PR uses 'main' as its head branch (common when contributors
push to their fork's default branch), the issue-handler job fails with
"fatal: a branch named 'main' already exists" because the initial
checkout already created a local 'main' branch.

Additionally, after redirecting origin to the fork, origin/$BASE_BRANCH
gets overwritten with the fork's ref, corrupting the diff base.

Fixes:
- Use fixed branch name 'pr-head' with -B (force-create) to avoid
  name collisions with existing branches
- Save base branch SHA before any origin URL changes so the diff
  always compares against the correct base

Tested against: https://github.com/amd/gaia/actions/runs/23859641383

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the devops DevOps/infrastructure changes label Apr 1, 2026
@kovtcharov
kovtcharov enabled auto-merge April 1, 2026 18:32
@kovtcharov
kovtcharov added this pull request to the merge queue Apr 1, 2026
Merged via the queue into main with commit 3f52582 Apr 1, 2026
24 checks passed
@kovtcharov
kovtcharov deleted the fix/claude-workflow-fork-checkout branch April 1, 2026 18:33
@itomek itomek mentioned this pull request Apr 10, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Apr 10, 2026
Release notes for v0.17.2. See
[docs/releases/v0.17.2.mdx](https://github.com/amd/gaia/blob/v0.17.2-release/docs/releases/v0.17.2.mdx)
for the full body.

**Headline features:**
- One-click desktop installers for Windows, macOS, and Linux (#731 +
#743)
- Customizable agents and Builder Agent (#720)
- MCP tool execution visibility in Agent Activity panel (#717)

**Security:** RAG cache integrity verification (#722, closes #447)

**Bug fixes:** drag-and-drop upload in any browser (#729), Linux install
fixes (#743)

**Release & CI:** unified publish workflow (#715), Claude review on fork
PRs (#685), npm OIDC fix (#683), webui package.json sync (#682)

Full changelog: v0.17.1...v0.17.2

---------

Co-authored-by: Tomasz Iniewicz <tomasz@iniewicz.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps/infrastructure changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants