nicokosi / hubstats

🧪 Command-line for GitHub pull request statistics
5 stars 0 forks source link

Fails for a public repository: HTTP 401 #53

Closed nicokosi closed 3 years ago

nicokosi commented 3 years ago
$ lein run --organization python --repository peps
Exception in thread "async-dispatch-1" clojure.lang.ExceptionInfo: status: 401 {:request-time 586, :request {:user-info nil, :headers {"Authorization" "token ", "Accept" "application/vnd.github.v3+json", "accept-encoding" "gzip, deflate"}, :server-port nil, :url "https://api.github.com/repos/python/peps/events?page=1", :http-request #object[jdk.internal.net.http.HttpRequestImpl 0x78f8a81a "https://api.github.com/repos/python/peps/events?page=1 GET"], :uri "/repos/python/peps/events", :server-name "api.github.com", :query-string "page=1", :scheme :https, :request-method :get}, :http-client #object[jdk.internal.net.http.HttpClientFacade 0x29391ed6 "jdk.internal.net.http.HttpClientImpl@c6d739f(1)"], :headers {"access-control-expose-headers" "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset", "referrer-policy" "origin-when-cross-origin, strict-origin-when-cross-origin", "server" "GitHub.com", "content-type" "application/json; charset=utf-8", "access-control-allow-origin" "*", "x-content-type-options" "nosniff", "content-length" "80", "x-frame-options" "deny", "strict-transport-security" "max-age=31536000; includeSubdomains; preload", "x-ratelimit-limit" "60", "x-ratelimit-remaining" "59", "x-ratelimit-reset" "1615663377", "x-github-request-id" "7039:3FA3:DA0959:E32B85:604D0301", "x-ratelimit-used" "1", "x-github-media-type" "github.v3; format=json", ":status" "401", "date" "Sat, 13 Mar 2021 18:22:57 GMT", "vary" "Accept-Encoding, Accept, X-Requested-With", "x-xss-protection" "1; mode=block", "content-security-policy" "default-src 'none'"}, :status 401, :content-type :application/json, :uri "https://api.github.com/repos/python/peps/events?page=1", :content-type-params {:charset "utf-8"}, :version :http-2, :body "{\"message\":\"Bad credentials\",\"documentation_url\":\"https://docs.github.com/rest\"}"}
    at hato.middleware$exceptions_response.invokeStatic(middleware.clj:149)
    at hato.middleware$exceptions_response.invoke(middleware.clj:140)
    at hato.middleware$wrap_exceptions$fn__1246.invoke(middleware.clj:158)
    at hato.middleware$wrap_accept$fn__1332.invoke(middleware.clj:315)
    at hato.middleware$wrap_accept_encoding$fn__1339.invoke(middleware.clj:337)
    at hato.middleware$wrap_multipart$fn__1499.invoke(middleware.clj:705)
    at hato.middleware$wrap_content_type$fn__1326.invoke(middleware.clj:298)
    at hato.middleware$wrap_form_params$fn__1427.invoke(middleware.clj:536)
    at hato.middleware$wrap_nested_params$fn__1493.invoke(middleware.clj:685)
    at hato.middleware$wrap_method$fn__1395.invoke(middleware.clj:470)
    at hato.client$request.invokeStatic(client.clj:314)
    at hato.client$request.doInvoke(client.clj:308)
    at clojure.lang.RestFn.invoke(RestFn.java:439)
    at hato.client$configure_and_execute.invokeStatic(client.clj:319)
    at hato.client$configure_and_execute.doInvoke(client.clj:316)
    at clojure.lang.RestFn.invoke(RestFn.java:442)
    at clojure.core$partial$fn__5858.invoke(core.clj:2629)
    at hubstats.github$github_api_events.invokeStatic(github.clj:15)
    at hubstats.github$github_api_events.invoke(github.clj:12)
    at hubstats.github$events.invokeStatic(github.clj:22)
    at hubstats.github$events.invoke(github.clj:18)
    at hubstats.github$events.invokeStatic(github.clj:25)
    at hubstats.github$events.invoke(github.clj:18)
    at hubstats.github$events.invokeStatic(github.clj:30)
    at hubstats.github$events.invoke(github.clj:18)
    at hubstats.github$pr_stats.invokeStatic(github.clj:73)
    at hubstats.github$pr_stats.invoke(github.clj:64)
    at hubstats.core$_main$fn__9880$state_machine__7222__auto____9897$fn__9899.invoke(core.clj:60)
    at hubstats.core$_main$fn__9880$state_machine__7222__auto____9897.invoke(core.clj:59)
    at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:978)
    at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:977)
    at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:982)
    at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:980)
    at hubstats.core$_main$fn__9880.invoke(core.clj:59)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at clojure.core.async.impl.concurrent$counted_thread_factory$reify__1962$fn__1963.invoke(concurrent.clj:29)
    at clojure.lang.AFn.run(AFn.java:22)
    at java.base/java.lang.Thread.run(Thread.java:834)

It does not fail when setting a token (even if it is not needed):

$ lein run --organization python --repository peps --token $GITHUB_TOKEN
pull requests for python/peps ->
    since 2021-03-06T18:23:45Z
        8 opened / 10 closed / 2 commented (11 comments)
        opened per author:  {markshannon 2, isidentical 2, iritkatriel 2, vstinner 1, mrahtz 1}
        comments per author:  {gvanrossum 6, iritkatriel 4, CAM-Gerlach 1}
        closed per author:  {markshannon 3, gvanrossum 3, isidentical 2, dstufft 1, brettcannon 1}
nicokosi commented 3 years ago

This is a regression introduced by commit 2edbca75a2675c4ba4764be5e32982f184eded6e.