PyGithub / PyGithub/PyGithub

System and Github server time difference is causing 401

オープン
#3,092 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
7.8k
フォーク
1.9k
平均マージ
17分
マージ済み PR(30日)
2

説明

During execution when PyGithub needs to refresh token it ran into problem. It was running smoothly before but at that moment started giving 401 errors. What appears to be the reason for this is caused by difference between time of local system and github servers. This error came around midnight local time. Generally it is not observed but for long running processes it might be critical.

Stack trace:

File "/usr/local/lib/python3.11/site-packages/github/Requester.py", line 548, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/Requester.py", line 713, in requestJson
    return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/Requester.py", line 798, in __requestEncode
    requestHeaders["Authorization"] = f"{self.__auth.token_type} {self.__auth.token}"
                                                                  ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/Auth.py", line 328, in token
    self.__installation_authorization = self._get_installation_authorization()
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/Auth.py", line 339, in _get_installation_authorization
    return self.__integration.get_access_token(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/GithubIntegration.py", line 228, in get_access_token
    headers, response = self.__requester.requestJsonAndCheck(
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/Requester.py", line 548, in requestJsonAndCheck
    return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/github/Requester.py", line 609, in __check
    raise self.createException(status, responseHeaders, data)
github.GithubException.GithubException: 401 {"message": "'Expiration time' claim ('exp') must be a numeric value representing the future time at which the assertion expires", "documentation_url": "https://docs.github.com/rest", "status": "401"}

A relevant issue issue was resolved here - https://github.com/octokit/auth-app.js/pull/164

The approach identifies the time diff b/w servers and adjust exp/iat accordingly.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Auth.py、特に _get_installation_authorization と token から始め、続いて GithubIntegration.py の get_access_token を通じてリクエストを追跡します。報告されている有効期限と発行時刻の処理を、リンク先の octokit/auth-app.js の pull request と比較します。長時間実行される token の更新で GitHub サーバーとの時刻差が考慮され、報告されている 401 の有効期限エラーで失敗しなくなれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
github, python
領域
api, authentication
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
42/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。