Skip to content

gh-address-comments fetch_comments.py resolves fork PRs against the head repo #495

Description

@Nick2bad4u

The gh-address-comments skill's scripts/fetch_comments.py seems to break on cross-repo PRs from a fork.

I hit this on JanDeDobbeleer/oh-my-posh#7582, where the PR head repo is my fork Nick2bad4u/oh-my-posh.

What happened:

Command failed: gh api graphql -F query=@- -F owner=Nick2bad4u -F repo=oh-my-posh -F number=7582
gh: Could not resolve to a PullRequest with the number of 7582.

The script calls:

pr = gh_pr_view_json("number,headRepositoryOwner,headRepository")
owner = pr["headRepositoryOwner"]["login"]
repo = pr["headRepository"]["name"]
number = int(pr["number"])

That works for same-repo PRs, but for fork PRs the PR number belongs to the base repository, not the head repository. In this case it tries to query Nick2bad4u/oh-my-posh#7582, but the actual PR is JanDeDobbeleer/oh-my-posh#7582.

Expected behavior:

The script should query the base repo for the PR, even when the current branch is from a fork. Something like reading the PR URL/base repository from gh pr view or using the base repo owner/name would avoid this.

I worked around it by querying GraphQL directly against JanDeDobbeleer/oh-my-posh#7582, and that returned the review threads correctly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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