Skip to content

Feature Request: On using a public token on a private repo and getting a 404, fail informatively #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
olleolleolle opened this issue Apr 15, 2016 · 9 comments
Labels
feature-request good-first-issue hacktoberfest Enjoy flashmob: https://hacktoberfest.digitalocean.com. Get a swag! help wanted

Comments

@olleolleolle
Copy link
Collaborator

olleolleolle commented Apr 15, 2016

This feature is about adding a good failure message for when the tool quits on the user in this situation:

  • using a private repository
  • and a Personal Access Token, which lacks the repos permission

When having mis-configured github-changelog-generator, with a token with the wrong permissions (it needs repos to work), the error output is:

/Users/totoro/.rvm/gems/ruby-2.3.0/gems/github_api-0.13.1/lib/github_api/response/raise_error.rb:14:in `on_complete': GET https://api.github.com/repos/mysecret/private-repo/tags: 404 Not Found (Github::Error::NotFound)
    from /Users/totoro/.rvm/gems/ruby-2.3.0/gems/faraday-0.9.2/lib/faraday/response.rb:9:in `block in call'
    from /Users/totoro/.rvm/gems/ruby-2.3.0/gems/faraday-0.9.2/lib/faraday/response.rb:57:in `on_complete'
    from /Users/totoro/.rvm/gems/ruby-2.3.0/gems/faraday-0.9.2/lib/faraday/response.rb:8:in `call'
    from /Users/totoro/.rvm/gems/ruby-2.3.0/gems/faraday-0.9.2/lib/faraday/response.rb:8:in `call'
    from /Users/totoro/.rvm/gems/ruby-2.3.0/gems/faraday-0.9.2/lib/faraday/response.rb:8:in `call'
    from /Users/totoro/.rvm/gems/ruby-2.3.0/gems/faraday-0.9.2/lib/faraday/response.rb:8:in `call'
    from /Users/totoro/.rvm/gems/ruby-2.3.0/gems/faraday-0.9.2/lib/faraday/request/url_encoded.rb:15:in `call'

This 404 from the GitHub API is an error which stops execution, and we could present a more informative error message, which speculated on possible causes and showed a link to the docs on making a token with private repo permissions.

Update for OctoKit: New error output, still unfriendly.

/Users/olle/.gem/ruby/2.4.0/gems/octokit-4.7.0/lib/octokit/response/raise_error.rb:16:in `on_complete': GET https://api.github.com/repos/ecraft/ecraft-deploy/tags?per_page=100: 404 - Not Found // See: https://developer.github.com/v3/repos/#list-tags (Octokit::NotFound)
	from /Users/olle/.gem/ruby/2.4.0/gems/faraday-0.13.1/lib/faraday/response.rb:9:in `block in call'
	from /Users/olle/.gem/ruby/2.4.0/gems/faraday-0.13.1/lib/faraday/response.rb:61:in `on_complete'
	from /Users/olle/.gem/ruby/2.4.0/gems/faraday-0.13.1/lib/faraday/response.rb:8:in `call'
	from /Users/olle/.gem/ruby/2.4.0/gems/faraday-http-cache-2.0.0/lib/faraday/http_cache.rb:290:in `fetch'
	from /Users/olle/.gem/ruby/2.4.0/gems/faraday-http-cache-2.0.0/lib/faraday/http_cache.rb:195:in `process'
	from /Users/olle/.gem/ruby/2.4.0/gems/faraday-http-cache-2.0.0/lib/faraday/http_cache.rb:142:in `call!'
	from /Users/olle/.gem/ruby/2.4.0/gems/faraday-http-cache-2.0.0/lib/faraday/http_cache.rb:115:in `call'
	from /Users/olle/.gem/ruby/2.4.0/gems/faraday-0.13.1/lib/faraday/rack_builder.rb:141:in `build_response'
	from /Users/olle/.gem/ruby/2.4.0/gems/faraday-0.13.1/lib/faraday/connection.rb:387:in `run_request'
	from /Users/olle/.gem/ruby/2.4.0/gems/faraday-0.13.1/lib/faraday/connection.rb:137:in `get'
	from /Users/olle/.gem/ruby/2.4.0/gems/sawyer-0.8.1/lib/sawyer/agent.rb:94:in `call'
	from /Users/olle/.gem/ruby/2.4.0/gems/octokit-4.7.0/lib/octokit/connection.rb:156:in `request'
	from /Users/olle/.gem/ruby/2.4.0/gems/octokit-4.7.0/lib/octokit/connection.rb:84:in `paginate'
	from /Users/olle/.gem/ruby/2.4.0/gems/octokit-4.7.0/lib/octokit/client/repositories.rb:481:in `tags'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/lib/github_changelog_generator/octo_fetcher.rb:78:in `block in calculate_pages'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/lib/github_changelog_generator/octo_fetcher.rb:297:in `block in check_github_response'
	from /Users/olle/.gem/ruby/2.4.0/gems/retriable-2.1.0/lib/retriable.rb:54:in `block in retriable'
	from /Users/olle/.gem/ruby/2.4.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `times'
	from /Users/olle/.gem/ruby/2.4.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `retriable'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/lib/github_changelog_generator/octo_fetcher.rb:296:in `check_github_response'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/lib/github_changelog_generator/octo_fetcher.rb:77:in `calculate_pages'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/lib/github_changelog_generator/octo_fetcher.rb:96:in `github_fetch_tags'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/lib/github_changelog_generator/octo_fetcher.rb:69:in `block in get_all_tags'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/lib/github_changelog_generator/octo_fetcher.rb:297:in `block in check_github_response'
	from /Users/olle/.gem/ruby/2.4.0/gems/retriable-2.1.0/lib/retriable.rb:54:in `block in retriable'
	from /Users/olle/.gem/ruby/2.4.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `times'
	from /Users/olle/.gem/ruby/2.4.0/gems/retriable-2.1.0/lib/retriable.rb:48:in `retriable'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/lib/github_changelog_generator/octo_fetcher.rb:296:in `check_github_response'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/lib/github_changelog_generator/octo_fetcher.rb:69:in `get_all_tags'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/lib/github_changelog_generator/generator/generator_tags.rb:9:in `fetch_and_filter_tags'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/lib/github_changelog_generator/generator/generator_generation.rb:8:in `compound_changelog'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/lib/github_changelog_generator.rb:34:in `run'
	from /Users/olle/.gem/ruby/2.4.0/gems/github_changelog_generator-1.14.2/bin/github_changelog_generator:5:in `<top (required)>'
	from /Users/olle/.gem/ruby/2.4.0/bin/github_changelog_generator:23:in `load'
	from /Users/olle/.gem/ruby/2.4.0/bin/github_changelog_generator:23:in `<main>'
Error output backtrace

Example output that I'm thinking of would be usable by someone trying to get this to work:

The <username>/<project> repository was not found. Does it exist? If private, did your personal access token have the "repos" permission?

@jdel7
Copy link
Contributor

jdel7 commented May 27, 2017

First timer here! Would really love to try and tackle this issue if I'm able to @olleolleolle

@olleolleolle
Copy link
Collaborator Author

Go ahead, make a test, make a PR, it's open!

@jdel7
Copy link
Contributor

jdel7 commented May 29, 2017

Hey @olleolleolle , is this still an issue even with the OctoKit gem? Or did the error change similar to #525 ?

@olleolleolle
Copy link
Collaborator Author

The errors from Octokit are good and fail with mention of the API, which helps guide the user.

But, the specific thing, the token privilege group repos being needed to have access to private repositories, that detail is not in the octokit message.

@olleolleolle
Copy link
Collaborator Author

I should change the description field to reflect that that is what we need, if anything.

@jdel7
Copy link
Contributor

jdel7 commented May 31, 2017

Hey @olleolleolle, really excited to get started. I've been trying to familiarize myself with the code here and have been trying to pin down where to start.

Just want to double check, but would this be a good starting place for this issue? https://github.com/skywinder/github-changelog-generator/blob/master/lib/github_changelog_generator/octo_fetcher.rb#L314-L317

Thank you for the guidance 😄

@olleolleolle
Copy link
Collaborator Author

olleolleolle commented May 31, 2017 via email

@olleolleolle
Copy link
Collaborator Author

I have updated the Description of the Issue with the new backtrace and error raised.

@olleolleolle
Copy link
Collaborator Author

olleolleolle commented Oct 13, 2017

Example output that I'm thinking of would be usable by someone trying to get this to work:

The <username>/<project> repository was not found. Does it exist? If private, did your personal access token have the "repos" permission?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request good-first-issue hacktoberfest Enjoy flashmob: https://hacktoberfest.digitalocean.com. Get a swag! help wanted
Projects
None yet
Development

No branches or pull requests

3 participants