babashka / neil

A CLI to add common aliases and features to deps.edn-based projects
MIT License
367 stars 27 forks source link

neil throws null pointer exception when past the GH json API rate limit #136

Closed ikappaki closed 1 year ago

ikappaki commented 1 year ago

Hi,

I've noticed that GH throws a NullPointer exception for some of its operations which call on the GH json API (e.g. querying about licences).

neil license search linense
----- Error --------------------------------------------------------------------
Type:     java.lang.NullPointerException
Location: d:\src\neil\neil:1386:36

----- Context ------------------------------------------------------------------
1382:                          curl-get-json
1383:                          (map #(select-keys % [:key :name])))
1384:         search-results (if search-term
1385:                          (filter #(str/includes?
1386:                                    (str/lower-case (:name %))
                                         ^--- 
1387:                                    (str/lower-case search-term))
1388:                                  license-vec)
1389:                          license-vec)]
1390:     (if (empty? search-results)
1391:       (binding [*out* *err*]

This can happen when the IP address where the user is runnign neil from an IP address that has exceeded the GH json api rate limit, which for most people using the tool will be 60 req per hour.

When this happens, it is not obvious to the user why neil fails.

To reproduce

  1. Check out neil
  2. run the neil test suite at least twice, it will fail the scond time
    bb tests
    # and again
    bb tests

    (a user can check their usage by running curl -I https://api.github.com/users/<gh user name>)

I understand this is a known limitation, but I could not find anything mentioned in neil's documentation about it or elsewhere.

I can think of the following options to solve this issue

  1. Explain in the documentation/neil usage output that this can happen while improving on error messages when this happens.
  2. as before, but also allow users to set their pershonal GH token with neil (personal tokens permit thousands of calls per hour), e.g. using an env variable where the user can set their token at and picked up by neil.
  3. Investigate alternatives ways to retrieve info from GH.

thanks