Skip to content

Fork PRs fail: action fetches branch by name instead of using refs/pull/N/head #1218

@RobotSail

Description

@RobotSail

Bug

When @claude is tagged on a PR that originates from a fork, the action fails with:

fatal: couldn't find remote ref <branch-name>

Root Cause

In src/modes/tag/index.ts / src/github/data/fetcher.ts, the action runs:

git fetch origin --depth=20 <branch-name>

For fork PRs, the branch only exists on the fork's remote, not on origin. GitHub exposes fork PR content at refs/pull/<number>/head, but the action doesn't use this ref.

Reproduction

  1. Have a repo with a PR from an external fork
  2. Comment @claude on that PR
  3. Action crashes at the git fetch step

Expected Behavior

The action should detect fork PRs and fetch using refs/pull/<number>/head instead of the branch name. For example:

git fetch origin "pull/${PR_NUMBER}/head:${BRANCH_NAME}"

Attempted Workarounds (all failed)

We tried pre-fetching the branch in a workflow step before the action runs:

- name: Pre-fetch fork PR branch
  run: |
    git fetch origin "pull/$PR_NUMBER/head:$HEAD_REF"
    git fetch origin "pull/$PR_NUMBER/head:refs/remotes/origin/$HEAD_REF"

Both the local branch and refs/remotes/origin/<branch> are successfully created, but the action still explicitly runs git fetch origin --depth=20 <branch> which contacts the remote and fails because the branch name doesn't exist there.

Additional Issue

When the action crashes during this setup phase, it does not update the initial comment it created to indicate the failure. The comment remains in a "working" state permanently.

Environment

  • anthropics/claude-code-action@v1 (SHA: 1c8b699d43e9bfed42b48ef15da85d89bab70960)
  • Using Vertex AI provider
  • Triggered via issue_comment event on a fork PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingp2Non-showstopper bug or popular feature request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions