hbstack / revision

HB revision module describe page with extra info, such as the created, modified dates and so on.
https://hbstack.dev/
MIT License
2 stars 2 forks source link

I added new files, didn't commit yet, and I have "Forbidden" error grom GitHub #110

Closed FuadEfendi closed 5 hours ago

FuadEfendi commented 2 days ago

ERROR [github.com/hbstack/revision] failed to fetch https://api.github.com/repos/MasteryEducation/SecuritiesExamsMastery.ca/commits?path=content/13/12/3/2/index.md: failed to fetch remote resource from 'https://api.github.com/repos/MasteryEducation/SecuritiesExamsMastery.ca/commits?path=content/13/12/3/2/index.md': Forbidden

FuadEfendi commented 2 days ago

I found that it is something GitHub recently changed: rate limits

{"message":"API rate limit exceeded for xx.xx.xx.xx (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"}

I never had such issues before and I often add 1000-2000 files, it didn't happen. github.com/hbstack/revision hits GitHub for each newly added (not committed yet) page.

I tried another project, which has about 1000 committed pages, this issue doesn't happen.

FuadEfendi commented 2 days ago

I think maybe my Internet speed is too fast ;) "rate limit" error rarely reproducible in the browser. I did commit changes, deployed successfully to Netlify, but still cannot run hugo server locally. Repository is "public".

As a workaround, I disabled "revision" module locally.

razonyang commented 2 days ago

each newly added (not committed yet) page

Newer created content should be excluded. I'll check this in a few days.

I believe these requests will count towards your account, regardless of the platform (local or remote, e.g Netlify).

The rate limit issue occurs if you make a high number of requests within an hour.

All of these requests count towards your personal rate limit of 5,000 requests per hour. https://docs.github.com/zh/rest/using-the-rest-api/rate-limits-for-the-rest-api?apiVersion=2022-11-28#primary-rate-limit-for-authenticated-users

I'd suggest disable the hb.revision.repo_contributors on config/development/params.yaml, so that it won't make requests to GitHub on development.

razonyang commented 2 days ago

BTW, even though the module caches those requests by modified date, you should still cache them (Hugo cachedir) on the platform side. Otherwise, the rate-limit counting will significantly increase on per deployment, since caches not found, module will re-make requests to API.

FuadEfendi commented 2 days ago

This is very strange; I heavily used the same config for another large site yesterday, it didn't happen at all. But I found one orphan unresponsive Hugo instance and killed it, maybe that's why.

razonyang commented 2 days ago

It's hard to fix without breaking changes, see #111, which require --enableGitInfo to be set and will break other sites after upgrading this module, so I'd leave this issue as open for now until find an ideal way.

razonyang commented 5 hours ago

Please enable the Git info feature after updating this module, otherwise the contributors section will never be displayed.