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

Fix unexpected exception in Google Calendar OAuth exchange #73963

Merged
merged 4 commits into from
Jun 28, 2022

Conversation

allenporter
Copy link
Contributor

@allenporter allenporter commented Jun 24, 2022

Proposed change

Rewrite google calendar oauth exchange callbacks. The goal is to prevent this error:

2022-06-14 17:04:39 INFO (SyncWorker_10) [oauth2client.client] Successfully retrieved access token
2022-06-14 17:04:39 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/google/api.py", line 123, in _poll_attempt
self._exchange_task_unsub()
TypeError: 'NoneType' object is not callable

I am not totally positive how it gets into this state, but it seemed worth trying to simplify anyway. The asserts have been replaced with explicit checks before running the unsub calls.

This replaces the asserts with some other rewrite of the logic to match more common patterns seen in other code in home assistant. Instead of having a single callback for updates and a timeout, the timeout is split into a separate listener. The new code is more lines of code, but seems like it could be a bit more straight forward avoiding passing callback parameters around.

The tests that use freezetime needed to be reverted because of spulec/freezegun#89 -- not sure if that was exposed because of moving patches around or specific callbacks around.

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

Additional information

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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • 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:

@frenck frenck added the smash Indicator this PR is close to finish for merging or closing label Jun 27, 2022
@balloob balloob merged commit 02d1676 into home-assistant:dev Jun 28, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bugfix by-code-owner cla-signed has-tests integration: google smash Indicator this PR is close to finish for merging or closing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Google Calendars - can't get authentication
4 participants