Skip to content
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

✨ GitHub card auth to increase rate limit #1417

Closed
Usual-Coder opened this issue Apr 16, 2024 · 3 comments
Closed

✨ GitHub card auth to increase rate limit #1417

Usual-Coder opened this issue Apr 16, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@Usual-Coder
Copy link

Usual-Coder commented Apr 16, 2024

Description

When using the GitHub card shortcode provided by Blowfish, Hugo fails to start.

How to reproduce

  1. Add a GitHub card somewhere (multiple cards will provoke the error faster 😏)
  2. Reload your page many times (aka more than 60 = like how it's done when developing / using livereload)
  3. Hugo server will fail and refuse to (re)start
  4. You'll get the error:
ERROR Failed to get JSON resource "https://api.github.com/repos/<NAMESPACE>/<REPO>": failed to retrieve remote file: Forbidden, body: "{\"message\":\"API rate limit exceeded for XXX.XXX.XX.XXX. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)\",\"documentation_url\":\"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting\"}\n"

NAMESPACE and REPO depending on the repository you're linking
XXX.XXX.XX.XXX being your IP address

Expected behavior

Avoid Hugo failure ... aka catch that failure in the corresponding partial and provide a fallback solution.

May I suggest an empty skeleton ... while waiting for the API to be reachable again?! 🀷
btw, instead of being empty (that could be misleading πŸ€”), the skeleton could include a rate warning to be more useful

Even better (that last part would obviously be a feature enhancement), provide a configuration param, so we could set a path to a specific secret file (or var ... handling both cases?! πŸ€”), allowing the use of tokens to avoid reaching the limit so easily 🀷

Environment

  • OS: Linux
  • Hugo: 0.124.1 (latest)
  • Blowfish theme: v2.65.0 (latest)

Additional context

On GitHub, the primary rate limit for unauthenticated requests is 60 requests per hour.

It seems that keeping multiple pages open (which is quite useful when writing with multiple languages and/or when building series, moving parts from one post to another) and forcing the reload (to update remote assets/data) will augment the odds of reaching the rate limit πŸ€” (benefits of Hugo's caching system being -necessarily- bypassed by the forced reloads)

Workaround πŸ˜‡

As proposed in the error log, you can temporarily (= until this issue is addressed) fix your Hugo configuration with:

ignoreLogs = ['error-remote-getjson']

Nothing will be displayed instead of provoking an error

@nunocoracao
Copy link
Owner

How many GitHub partials are you using?

@nunocoracao nunocoracao added question Further information is requested investigating investigating the issue waiting info labels Apr 16, 2024
@Usual-Coder
Copy link
Author

Hi ... I'm just starting to write content = the problem appeared on a page I dedicate to credits = GitHub cards will be reduced around 10, for now 🀷

May I say I don't think the problem is related to the amount of cards (even if it obviously augments the odds of occurrence) but to the edge case of the necessarily forced reloads, during development.

Btw, I'm not expecting the kind of traffic that will provoke such an error once "on production" (the website will probably not be hit that much 😏 ... and more importantly the cache would do its job).

While everything here is up to you, after reflection, being such an edge case, I don't think it's worth the time to fix it properly πŸ€” I'd put that way down on your backlog (= fix only if more people complain) + in the meantime I'd go with a simple warning in your docs and the workaround evoked previously 🀷

@nunocoracao nunocoracao added enhancement New feature or request and removed question Further information is requested investigating investigating the issue waiting info labels Apr 19, 2024
@nunocoracao nunocoracao changed the title GitHub card provokes an error due to the rate limit being exceeded ✨ GitHub card auth to increase rate limit Apr 19, 2024
@nunocoracao
Copy link
Owner

Closing after reco from OP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants