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

Guard for when refreshing token fails #43855

Merged
merged 1 commit into from
Dec 2, 2020
Merged

Guard for when refreshing token fails #43855

merged 1 commit into from
Dec 2, 2020

Conversation

balloob
Copy link
Member

@balloob balloob commented Dec 2, 2020

Breaking change

Proposed change

When starting up Spotify I got 503 error and the integration was unable to recover. Fixed this by wrapping the refresh token logic at startup and handle errors.

Traceback (most recent call last):
  File "/home/paulus/dev/hass/core/homeassistant/config_entries.py", line 236, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/home/paulus/dev/hass/core/homeassistant/components/spotify/__init__.py", line 65, in async_setup_entry
    await session.async_ensure_token_valid()
  File "/home/paulus/dev/hass/core/homeassistant/helpers/config_entry_oauth2_flow.py", line 465, in async_ensure_token_valid
    new_token = await self.implementation.async_refresh_token(self.token)
  File "/home/paulus/dev/hass/core/homeassistant/helpers/config_entry_oauth2_flow.py", line 84, in async_refresh_token
    new_token = await self._async_refresh_token(token)
  File "/home/paulus/dev/hass/core/homeassistant/helpers/config_entry_oauth2_flow.py", line 175, in _async_refresh_token
    new_token = await self._token_request(
  File "/home/paulus/dev/hass/core/homeassistant/helpers/config_entry_oauth2_flow.py", line 194, in _token_request
    resp.raise_for_status()
  File "/home/paulus/dev/hass/core/venv/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 1002, in raise_for_status
    raise ClientResponseError(
aiohttp.client_exceptions.ClientResponseError: 503, message='Service Unavailable', url=URL('https://accounts.spotify.com/api/token')

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link

Hey there @frenck, mind taking a look at this pull request as its been labeled with an integration (spotify) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@frenck frenck merged commit 06626af into dev Dec 2, 2020
@frenck frenck deleted the spotify-catch-errors branch December 2, 2020 13:55
@github-actions github-actions bot locked and limited conversation to collaborators Dec 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants