404 Git diff of pull request
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 7.8k
- フォーク
- 1.9k
- 平均マージ
- 17分
- マージ済み PR(30日)
- 2
説明
I have Github App installed on my private testing repository.
I am trying to get the actual git diff content of a pull request (not just the url).
If I access the diff endpoint in my browser, I get the expected output, so the endpoint, which pr.diff_url provides is correct. Important note is that when I access it from the browser, there is a token parameter added.
here is my authentication process:
auth = github.Auth.AppAuth(app_id, app_key)
gi = github.GithubIntegration(auth=auth)
installation_id = vars.private_repo_installation_id
try:
installation = gi.get_app_installation(installation_id)
except Exception as e:
print("Installation not found.")
exit()
g = installation.get_github_for_installation()
repo = g.get_repo(<repo-name>)
pr = repo.get_pull(<pr-number>)
then, using the requests library:
response = requests.get(pr.diff_url)
if response.status_code == 200:
diff_content = response.text
else:
print(f"Failed to fetch diff content. Status code: {response.status_code}")
For public repos, it works fine, but for private repositories, I get status code 404.
I assumed it was the lack of authentication (although the status code is 404, not 403 or 401)
so I added:
headers = {"Authorization": f"token {gi.get_access_token(installation_id)}"}
and later in the request:
response = requests.get(pr.diff_url, headers=headers)
yet the 404 persists.
but I am unsure how to use it, couldn't find any examples in the documentation. The following code still encounters 404 error:
token = gi.get_access_token(installation_id)
token = token.token
url = pr.diff_url + '?token=' + token
response = requests.get(url)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、示されている GitHub App 認証フローを使用してプライベートリポジトリのケースを再現し、その後、pr.diff_url とインストールアクセストークンがどのように扱われているかを調べます。認証済みリクエストが 404 を返す理由を特定し、プルリクエストの diff コンテンツを取得するためにサポートされている方法を文書化または修正できれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- github, python
- 領域
- api
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100