Skip to content

add_pr_review_comment fails on PRs from forks: it looks for origin/<head_ref> #4645

Description

@jefgen

Short summary

Staging a review comment on a PR from a fork fails with "Failed to resolve PR head".

Affected version or release

1.1.28 (Windows ARM64)

Installation context

Windows desktop app, in a PR-backed worktree session for a PR whose head branch is in a fork.

What happened?

add_pr_review_comment failed before staging anything:

Failed to resolve PR head: git ["rev-parse", "--verify", "origin/<head_ref>^{commit}"] failed: fatal: Needed a single revision

For a fork PR, the app tracks the head through its own remote, pr-<owner>-<repo>, and the worktree branch's upstream is pr-<owner>-<repo>/<head_ref>. origin has no branch by that name, so the lookup can't succeed.

Steps to reproduce

  1. Open a PR-backed session for a PR from a fork.
  2. Ask the agent to stage a review comment on an added line.
  3. The call fails with the error above, and nothing is staged.

Expected behavior

The comment is staged against the PR head, resolved through the remote the app set up for the fork, or through refs/pull/<n>/head.

Additional context

Workaround: git update-ref refs/remotes/origin/<head_ref> <PR head SHA>, after which staging works. The ref doesn't move when the fork's branch does, so it has to be updated before staging against a newer head.

Co-authored by Copilot + Human. 🤖👩‍💻

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions