Skip to content

Bug: get_diff_of_pull_request fails for private repositories #726

Description

@aarogyarijal

Bug Description

The get_diff_of_pull_request function in src/git_bob/_github_utilities.py isn't working for private GitHub repositories. It fetches pull request diffs just fine when the repository is public, but as soon as it's private, it fails.

Steps to Reproduce

  1. Make sure git-bob is set up with a GitHub API key that has access to a private repository.
  2. Open a pull request in that private repository.
  3. Try to use any git-bob feature that relies on get_diff_of_pull_request (e.g., the commenting or reviewing features for pull requests in _ai_github_utilities.py).

Expected Behavior

We expect get_diff_of_pull_request to retrieve diffs from both public and private repositories without issue, assuming the authenticated PyGithub instance has the right permissions.

Actual Behavior

When trying to get a pull request diff from a private repository, the requests.get() call to pull_request.diff_url returns Error: 404 Not Found, which means the diff content can't be retrieved.

Root Cause

Maybe the problem is that the requests.get() call on line _github_utilities.py:622 doesn't include the necessary headers. See below link for more.

Additional Links

https://github.com/orgs/community/discussions/24460#discussioncomment-3244157

git-bob comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions