home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.08k stars 31.09k forks source link

forecast_solar sporadically errors with KeyError: 'X-Ratelimit-Limit' #131786

Closed mmattel closed 2 days ago

mmattel commented 2 days ago

The problem

forecast_solar sporadically errors with KeyError: 'X-Ratelimit-Limit' The key query should be error proof and if a key issue occurs, a warning should be printed instead.

2024-11-27 07:23:59.607 ERROR (MainThread) [homeassistant.components.forecast_solar] Unexpected error fetching forecast_solar data
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 382, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/forecast_solar/coordinator.py", line 69, in _async_update_data
    return await self.forecast.estimate()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/forecast_solar/__init__.py", line 194, in estimate
    data = await self._request(
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/forecast_solar/__init__.py", line 139, in _request
    self.ratelimit = Ratelimit.from_response(response)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/forecast_solar/models.py", line 211, in from_response
    limit = int(response.headers["X-Ratelimit-Limit"])
                ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
KeyError: 'X-Ratelimit-Limit'

What version of Home Assistant Core has the issue?

core-2024.11.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

forecast_solar

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 2 days ago

Hey there @klaasnicolaas, @frenck, mind taking a look at this issue as it has been labeled with an integration (forecast_solar) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `forecast_solar` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign forecast_solar` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


forecast_solar documentation forecast_solar source (message by IssueLinks)

klaasnicolaas commented 2 days ago

Please check first if there are any existing issues created about this before creating a new one 😉

Duplicate of #131687

./Klaas