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

Remove no-longer-needed invalid API key monitor for OpenUV #85573

Merged
merged 3 commits into from
Jan 10, 2023

Conversation

bachya
Copy link
Contributor

@bachya bachya commented Jan 9, 2023

Proposed change

OpenUV has a new API method that reliably returns the API's current status. This allows us to remove the "track how many errors we receive to see if we're looking at an invalid API key or service disruption" logic introduced in #79691. Doing so fixes a bug in which the integration will, upon config entry setup, attempt a re-setup every 1-2 minutes and spam the logs if its API key has reached its limit (#85496).

There is one quirk to keep in mind. In OpenUV, an HTTP 403 response indicates one of two conditions:

  1. An invalid API key
  2. An API key whose daily/monthly limit is reached

Unfortunately, we can't deduce which is which when we receive an HTTP 403 (there is an API endpoint to determine how many calls a user has made per day/month, but there is no way to know what that particular user's call limit is 🤦🏻). So, we follow this strategy:

  1. Any HTTP 403 will trigger a re-auth flow.
  2. In the case of an overrun API call limit, once the limit expires and the coordinator successfully retrieves data, any existing re-auth flow is canceled.

pyopenuv changelog: https://github.com/bachya/pyopenuv/releases/tag/2023.01.0
pyopenuv diff: bachya/pyopenuv@2022.04.0...2023.01.0 (large diff, but the vast majority of it is repo maintenance)

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)
  • Deprecation (breaking change to happen in the future)
  • 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.

To help with the load of incoming pull requests:

Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice cleanup, thanks @bachya 👍

@emontnemery emontnemery merged commit 6a801fc into home-assistant:dev Jan 10, 2023
@bachya
Copy link
Contributor Author

bachya commented Jan 10, 2023

Thanks, @emontnemery!

@bachya bachya deleted the openuv-bump branch January 10, 2023 18:06
balloob pushed a commit that referenced this pull request Jan 10, 2023
* Remove no-longer-needed invalid API key monitor for OpenUV

* Handle re-auth cancellation

* Use automatic API status check
@balloob balloob mentioned this pull request Jan 10, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 11, 2023
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.

OpenUV keeps hammering the API on error
3 participants