zerocracy / pages-action

GitHub Action that generates HTML report from a Factbase
MIT License
5 stars 0 forks source link

`User not found` leads to runtime exception #131

Open yegor256 opened 1 week ago

yegor256 commented 1 week ago

I found this problem here:

Octokit::Forbidden: GET https://api.github.com/user/29139614: 403 - Resource not accessible by integration // See: https://docs.github.com/rest
    /usr/local/bundle/gems/octokit-9.1.0/lib/octokit/response/raise_error.rb:14:in `on_complete'
    /usr/local/bundle/gems/faraday-2.10.1/lib/faraday/middleware.rb:57:in `block in call'
    /usr/local/bundle/gems/faraday-2.10.1/lib/faraday/response.rb:42:in `on_complete'
    /usr/local/bundle/gems/faraday-2.10.1/lib/faraday/middleware.rb:56:in `call'
    /usr/local/bundle/gems/faraday-http-cache-2.5.1/lib/faraday/http_cache.rb:286:in `fetch'
    /usr/local/bundle/gems/faraday-http-cache-2.5.1/lib/faraday/http_cache.rb:190:in `process'
    /usr/local/bundle/gems/faraday-http-cache-2.5.1/lib/faraday/http_cache.rb:141:in `call!'
    /usr/local/bundle/gems/faraday-http-cache-2.5.1/lib/faraday/http_cache.rb:121:in `call'
    /usr/local/bundle/gems/fbe-0.0.53/lib/fbe/middleware/quota.rb:48:in `call'
    /usr/local/bundle/gems/faraday-retry-2.2.1/lib/faraday/retry/middleware.rb:153:in `call'
    /usr/local/bundle/gems/faraday-2.10.1/lib/faraday/rack_builder.rb:152:in `build_response'
    /usr/local/bundle/gems/faraday-2.10.1/lib/faraday/connection.rb:444:in `run_request'
    /usr/local/bundle/gems/faraday-2.10.1/lib/faraday/connection.rb:200:in `get'
    /usr/local/bundle/gems/sawyer-0.9.2/lib/sawyer/agent.rb:[99](https://github.com/zerocracy/judges-action/actions/runs/10900854041/job/30249395419#step:6:100):in `call'
    /usr/local/bundle/gems/octokit-9.1.0/lib/octokit/connection.rb:156:in `request'
    /usr/local/bundle/gems/octokit-9.1.0/lib/octokit/connection.rb:19:in `get'
    /usr/local/bundle/gems/octokit-9.1.0/lib/octokit/client/users.rb:34:in `user'
    /usr/local/bundle/gems/verbose-0.0.2/lib/verbose.rb:48:in `method_missing'
    /usr/local/bundle/gems/fbe-0.0.53/lib/fbe/octo.rb:115:in `user_name_by_id'
    /home/judges/add-user-names/add-user-names.rb:31:in `block (2 levels) in <top (required)>'Octokit::Forbidden: GET https://api.github.com/user/29139614: 403 - Resource not accessible by integration // See: https://docs.github.com/rest
    /usr/local/bundle/gems/octokit-9.1.0/lib/octokit/response/raise_error.rb:14:in `on_complete'
    /usr/local/bundle/gems/faraday-2.10.1/lib/faraday/middleware.rb:57:in `block in call'
    /usr/local/bundle/gems/faraday-2.10.1/lib/faraday/response.rb:42:in `on_complete'
    /usr/local/bundle/gems/faraday-2.10.1/lib/faraday/middleware.rb:56:in `call'
    /usr/local/bundle/gems/faraday-http-cache-2.5.1/lib/faraday/http_cache.rb:286:in `fetch'
    /usr/local/bundle/gems/faraday-http-cache-2.5.1/lib/faraday/http_cache.rb:190:in `process'
    /usr/local/bundle/gems/faraday-http-cache-2.5.1/lib/faraday/http_cache.rb:141:in `call!'
    /usr/local/bundle/gems/faraday-http-cache-2.5.1/lib/faraday/http_cache.rb:121:in `call'
    /usr/local/bundle/gems/fbe-0.0.53/lib/fbe/middleware/quota.rb:48:in `call'
    /usr/local/bundle/gems/faraday-retry-2.2.1/lib/faraday/retry/middleware.rb:153:in `call'
    /usr/local/bundle/gems/faraday-2.10.1/lib/faraday/rack_builder.rb:152:in `build_response'
    /usr/local/bundle/gems/faraday-2.10.1/lib/faraday/connection.rb:444:in `run_request'
    /usr/local/bundle/gems/faraday-2.10.1/lib/faraday/connection.rb:200:in `get'
    /usr/local/bundle/gems/sawyer-0.9.2/lib/sawyer/agent.rb:[99](https://github.com/zerocracy/judges-action/actions/runs/10900854041/job/30249395419#step:6:100):in `call'
    /usr/local/bundle/gems/octokit-9.1.0/lib/octokit/connection.rb:156:in `request'
    /usr/local/bundle/gems/octokit-9.1.0/lib/octokit/connection.rb:19:in `get'
    /usr/local/bundle/gems/octokit-9.1.0/lib/octokit/client/users.rb:34:in `user'
    /usr/local/bundle/gems/verbose-0.0.2/lib/verbose.rb:48:in `method_missing'
    /usr/local/bundle/gems/fbe-0.0.53/lib/fbe/octo.rb:115:in `user_name_by_id'
    /home/judges/add-user-names/add-user-names.rb:31:in `block (2 levels) in <top (required)>'

Probably, the user is deleted and that's why we fail.

Yegorov commented 1 week ago

@yegor256 As I see this error refers to this project, see this line:

/home/judges/add-user-names/add-user-names.rb:31:in `block (2 levels) in <top (required)>'Octokit::Forbidden

Maybe this issue needs to be transferred to that project? If I understand it correctly, then it is necessary to ignore Octokit::ClientError exception here Can i fix it?

yegor256 commented 1 week ago

@Yegorov you are right, transferred

yegor256 commented 1 week ago

@Yegorov maybe it's possible to check the presence of a user via GitHub API? Just ignoring all client errors is not a good idea.

Yegorov commented 6 days ago

@yegor256 it was a false assumption that the user was deleted or not found

octo.user(29139614)
GET https://api.github.com/user/29139614
D: Octokit::Client.user(29139614) in 512ms
 =>
{:login=>"renovate[bot]",
 :id=>29139614,

If the user does not exist, then there must be an error: 404 - Not Found

octo.user(11)
D: Octokit::Client.user(11) in 454ms
/home/artem/.rvm/gems/ruby-3.3.4/gems/octokit-9.1.0/lib/octokit/response/raise_error.rb:14:in `on_complete': GET https://api.github.com/user/11: 404 - Not Found // See: https://docs.github.com/rest (Octokit::NotFound)
        from /home/artem/.rvm/gems/ruby-3.3.4/gems/faraday-2.10.1/lib/faraday/middleware.rb:57:in `block in call'
        from /home/artem/.rvm/gems/ruby-3.3.4/gems/faraday-2.10.1/lib/faraday/response.rb:42:in `on_complete'
        from /home/artem/.rvm/gems/ruby-3.3.4/gems/faraday-2.10.1/lib/faraday/middleware.rb:56:in `call'
        from /home/artem/.rvm/gems/ruby-3.3.4/gems/faraday-http-cache-2.5.1/lib/faraday/http_cache.rb:286:in `fetch'
        from /home/artem/.rvm/gems/ruby-3.3.4/gems/faraday-http-cache-2.5.1/lib/faraday/http_cache.rb:190:in `process'
        from /home/artem/.rvm/gems/ruby-3.3.4/gems/faraday-http-cache-2.5.1/lib/faraday/http_cache.rb:141:in `call!'
        from /home/artem/.rvm/gems/ruby-3.3.4/gems/faraday-http-cache-2.5.1/lib/faraday/http_cache.rb:121:in `call'
        from /home/artem/projects2/zerocracy/fbe/lib/fbe/middleware/quota.rb:48:in `call'

Error 403 - Resource not accessible by integration based on the documentation is related to rate limiting:

If you exceed your primary rate limit, you will receive a 403 Forbidden or 429 Too Many Requests response, and the x-ratelimit-remaining header will be 0. If you exceed a secondary rate limit, you will receive a 403 Forbidden or 429 Too Many Requests response and an error message that indicates that you exceeded a secondary rate limit.

We cannot find out why Github answered with this 403 Forbidden error and not 429 Too Many Requests because there was no logger

I propose to implement logging only answers with statuses of more than 400 to find out the cause of this error. What do you think?

yegor256 commented 6 days ago

@Yegorov I like the idea of making logging more verbose. Now, we use Loog::NULL, while loog is provided as an argument of Fbe.octo. This looks wrong. However, just passing loog instead of Loog::NULL may lead to very verbose log output. Try to fix this, but be aware of the problem: logs must not be noisy when loog is Loog::REGULAR.

yegor256 commented 2 days ago

@rultor release, tag is 0.0.35

rultor commented 2 days ago

@rultor release, tag is 0.0.35

@yegor256 OK, I will release it now. Please check the progress here

rultor commented 2 days ago

@rultor release, tag is 0.0.35

@yegor256 Done! FYI, the full log is here (took me 34min)