mattduck / gh2md

Export Github repository issues, pull requests and comments to markdown.
MIT License
254 stars 45 forks source link

Can't fetch issues from public repo #26

Closed kirillt closed 2 years ago

kirillt commented 2 years ago
[kirill@lenovo tmp]$ gh2md ethereum/EIPs --no-prs --multiple-files eips/
[2022-03-29 10:39:54,161] [INFO] Looking for token in file: /home/kirill/.config/gh2md/token
[2022-03-29 10:39:54,161] [INFO] Looking for token in file: /home/kirill/.github-token
[2022-03-29 10:39:54,161] [WARNING] No token found. Access to private repositories will fail
[2022-03-29 10:39:54,161] [INFO] Initiating fetch for repo: ethereum/EIPs
[2022-03-29 10:39:54,162] [WARNING] Exception response from request attempt 1
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/gh2md/gh2md.py", line 364, in _post
    resp = self._request_session().post(
  File "/usr/local/lib/python3.8/site-packages/gh2md/gh2md.py", line 350, in _request_session
    self._session.headers.update({"Authorization": "token " + self.token})
TypeError: can only concatenate str (not "NoneType") to str
[2022-03-29 10:39:57,592] [WARNING] Exception response from request attempt 2
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/gh2md/gh2md.py", line 367, in _post
    resp.raise_for_status()
  File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.github.com/graphql
[2022-03-29 10:40:00,595] [ERROR] Request failed multiple retries, returning empty data
[2022-03-29 10:40:00,595] [ERROR] Repository data missing in response, can't proceed
Traceback (most recent call last):
  File "/usr/local/bin/gh2md", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.8/site-packages/gh2md/gh2md.py", line 791, in main
    repo = gh.fetch_and_decode_repository(
  File "/usr/local/lib/python3.8/site-packages/gh2md/gh2md.py", line 566, in fetch_and_decode_repository
    repo_data = response["data"]["repository"]
KeyError: 'data'
ronna commented 2 years ago

Hi @kirillt

You need to set the Github token even if you just want to pull public repos.

mattduck commented 2 years ago

Thanks for raising - I can update the docs + error handling here to make this more explicit

mattduck commented 2 years ago

Exiting and error output has been updated in 2.3.0, hopefully this is more explicit for everyone in future:

$ gh2md mattduck/gh2md export.md
[2022-07-17 10:58:26,888] [INFO] Looking for token in envvar GITHUB_ACCESS_TOKEN
[2022-07-17 10:58:26,888] [INFO] Looking for token in file: /f/users/matt/.config/gh2md/token
[2022-07-17 10:58:26,889] [INFO] Looking for token in file: /f/users/matt/.github-token
No Github access token found, exiting. Use gh2md --help so see options for providing a token.