Github rate limit error HACS

Installed HACS yesterday and encountered the “HACS is disabled” warning. Restarted HA today and now the error is gone.

where is the hacs folder? thanks

I have been hitting this issue for a couple of months now, but didn’t have the courage to try to fix it because of my limited skills. But after reading several links for some time I decided to reinstall HACS, meaning first removing it and then installing it from scratch following these instructions.

This is what is in my ./config/custom_components folder:

This is what is in my .config/.storage folder:

And HACS isn’t listed as one of the installed integrations:

I then tried to install HACS from the GUI:

…and got this error:

So I went back to the HACS install instructions for a core config. I get this error when trying to download HACS:
image

Clearly I screwed up something quite badly. Any ideas?

This is my System Health report:

System Health

version: core-2022.5.5
installation_type: Home Assistant OS
dev: false
hassio: true
docker: true
user: root
virtualenv: false
python_version: 3.9.9
os_name: Linux
os_version: 5.15.41
arch: x86_64
timezone: Europe/Lisbon


logged_in: true
subscription_expiration: 14 June 2022, 01:00
relayer_connected: true
remote_enabled: true
remote_connected: true
alexa_enabled: false
google_enabled: true
remote_server: eu-central-1-2.ui.nabu.casa
can_reach_cert_server: ok
can_reach_cloud_auth: ok
can_reach_cloud: ok


host_os: Home Assistant OS 8.1
update_channel: stable
supervisor_version: supervisor-2022.05.3
docker_version: 20.10.14
disk_total: 116.7 GB
disk_used: 36.1 GB
healthy: true
supported: true
board: generic-x86-64
supervisor_api: ok
version_api: ok
installed_addons: Samba share (9.6.1), Home Assistant Google Drive Backup (0.107.2), Check Home Assistant configuration (3.10.0), Terminal & SSH (9.4.0), Network UPS Tools (0.10.0), Studio Code Server (5.0.4), Samba Backup (5.0.0), Mosquitto broker (6.1.2)


api_endpoint_reachable: ok


dashboards: 7
resources: 7
views: 32
mode: storage

So I’ve got myself into a difficult spot. I couldn’t reinstall HACS so I restored a backup from before I started the removal process. The only problem is that I deleted the GitHub token, so now I get an invalid token error!!

I tried to reconfigure HACS from the Integrations page, and get presented with this popup:

I do not get the prompt for the token as described in these HACS instructions, but the process stops without an error.
image

I guess I have to go through the manual configuration at this point? So I tried creating the GitHub token following the instructions in the HACS documentation, but I didn’t know what scope I should select so went conservative. Is this enough of a scope?

I no longer get the HACS is disabled - Invalid token error, so I presume the scope I set for the GitHub token is sufficient.

However, after trying to install the HACS update and rebooting, I still get the message that a newer version of HACS is available on the Settings page.

So no improvement after a week. I do not get a token error so I assume that is working just fine.

This is the result from https://api.github.com/rate_limit with my indentation for ease of reading.

{"resources":{
  "core":{
    "limit":60,
    "remaining":60,
    "reset":1654519047,
    "used":0,
    "resource":"core"},
  "graphql":{ 
    "limit":0,
    "remaining":0,
    "reset":1654519047,
    "used":0,
    "resource":"graphql"},
  "integration_manifest":{ 
    "limit":5000,
    "remaining":5000,
    "reset":1654519047,
    "used":0,
    "resource":"integration_manifest"},
  "search":{
    "limit":10,
    "remaining":10,
    "reset":1654515507,
    "used":0,
    "resource":"search"}},
"rate":{
  "limit":60,
  "remaining":60,
  "reset":1654519047,
  "used":0,
  "resource":"core"}}

From this result I cannot see any rate limit. But on the HACS page I see this:

If I click on the update for HACS I get this window:

When I click on the UPDATE button the button changes to an animated circle. After about 30 secs the screen reverts to the page above showing all the available HACS updates, including the Background tasks pending message.

Below are all the logs related to HACS:

While the rate limit error is displayed, there are several other errors which I do not understand. Any points will be accepted with great gratetude.

im unable to setup HACS, its stalled at waiting for device activation
raceback (most recent call last):
File “/config/custom_components/hacs/config_flow.py”, line 62, in _wait_for_activation
response = await self.device.activation(device_code=self._login_device.device_code)
File “/usr/local/lib/python3.10/site-packages/aiogithubapi/device.py”, line 160, in activation
raise GitHubException(response.data.get(“error_description”))
aiogithubapi.exceptions.GitHubException: Too many requests have been made in the same timeframe.

been trying for two days now

I hit the rate limit for the first time this morning, after running HACS for maybe a year. The first thing I tried to do was to delete the .storage\hacs folder. Then I restarted the host and restarted HA itself. The ratelimit error remained.

My default calc in base.py is different, and so I haven’t made any changes. This is what mine looks like:

   async def async_can_update(self) -> int:
        """Helper to calculate the number of repositories we can fetch data for."""
        try:
            response = await self.async_github_api_method(self.githubapi.rate_limit)
            if ((limit := response.data.resources.core.remaining or 0) - 1000) >= 10:
                return math.floor((limit - 1000) / 10)
            reset = dt.as_local(dt.utc_from_timestamp(response.data.resources.core.reset))
            self.log.info(
                "GitHub API ratelimited - %s remaining (%s)",
                response.data.resources.core.remaining,
                f"{reset.hour}:{reset.minute}:{reset.second}",
            )
            self.disable_hacs(HacsDisabledReason.RATE_LIMIT)
        except BaseException as exception:  # lgtm [py/catch-base-exception] pylint: disable=broad-except
            self.log.exception(exception)

        return 0

Adding this to my configuration.yaml and then restarting worked for me:

config:
  - hacs.disable(HacsDisabledReason.RATE_LIMIT) return True

Thanks, @masteryoda and @ballakers.

1 Like

This is absolute bonkers, everyone here that have added that “fix” to their config, REMOVE IT.
Firstly it does NOTHING. it can actually give you issues with home assistant later.

The “check” by navigating to an URL to check is 100% wrong (that is for unauthenticated calls).
The information in system health show correctly.

As for 60, yeah that’s wrong as well, it’s 5000. 60 is when you are not authenticated.

The solution is simple, wait 1 hour.
Or enable experimental features.

4 Likes

Sorry waiting an hour is not a fix if after an hour or 10 or more its till doesn’t work.
Before you could add a token in the config file but not any more, This is the 2nd time I have tried to install HACS on a different to my main Home assistant - I am trying to build anew machine as my Raspberry PI 4B is now very old, So i have purchased a Raspberry pi 5 with an NME drive, the fact you can’t restore from a complete backup - so restoreing most things from the backup - then comes HACS that likes a reinstall except even when github passes authorization HACS doesn’t except it - all attempts at bypassing this are frowned on - why doesn’t HACS say I will auomatically try again every hour until it works :smile:

1 Like