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

Config entry state is mutated externally #3537

Open
7 tasks done
bdraco opened this issue Mar 1, 2024 · 3 comments
Open
7 tasks done

Config entry state is mutated externally #3537

bdraco opened this issue Mar 1, 2024 · 3 comments
Labels
issue:backend For issues with the backend/integration

Comments

@bdraco
Copy link
Contributor

bdraco commented Mar 1, 2024

System Health details

n/a

Checklist

Describe the issue

self.configuration.config_entry.state = ConfigEntryState.SETUP_ERROR

I added a check for this in home-assistant/core#110023 because the code in config entries assumes .state is an internal state does not handle it being changed out from under it (changing externally means we don't dispatch the state change to the UI, or update the retry count)

Reproduction steps

Have an invalid token

Debug logs

2024-03-01 11:26:44.322 ERROR (MainThread) [custom_components.hacs] HACS is disabled - invalid_token
2024-03-01 11:26:44.323 ERROR (MainThread) [custom_components.hacs] state cannot be changed
Traceback (most recent call last):
  File "/Users/bdraco/home-assistant/config/custom_components/hacs/base.py", line 511, in async_github_api_method
    return await method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bdraco/home-assistant/venv/lib/python3.12/site-packages/aiogithubapi/github.py", line 224, in rate_limit
    response = await self._client.async_call_api(endpoint="/rate_limit", **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bdraco/home-assistant/venv/lib/python3.12/site-packages/aiogithubapi/client.py", line 146, in async_call_api
    raise exception(message or response.data)
aiogithubapi.exceptions.GitHubAuthenticationException: Bad credentials

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/bdraco/home-assistant/config/custom_components/hacs/base.py", line 471, in async_can_update
    response = await self.async_github_api_method(self.githubapi.rate_limit)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bdraco/home-assistant/config/custom_components/hacs/base.py", line 513, in async_github_api_method
    self.disable_hacs(HacsDisabledReason.INVALID_TOKEN)
  File "/Users/bdraco/home-assistant/config/custom_components/hacs/base.py", line 408, in disable_hacs
    self.configuration.config_entry.state = ConfigEntryState.SETUP_ERROR
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/bdraco/home-assistant/homeassistant/config_entries.py", line 413, in __setattr__
    raise AttributeError(f"{key} cannot be changed")
AttributeError: state cannot be changed


### Diagnostics dump

_No response_
@bdraco bdraco added the issue:backend For issues with the backend/integration label Mar 1, 2024
@hacs-bot
Copy link

hacs-bot bot commented Mar 1, 2024

Make sure you have read the issue guidelines and that you filled out the entire template.

If you have an issue identical to this, do not add comments like "same here", "i have this too", instead add a 👍 reaction to the issue description. Thanks! 👍

@ludeeus
Copy link
Member

ludeeus commented Mar 1, 2024

How did yo manage that?
It should not be possible to use a token anymore 🤔

@bdraco
Copy link
Contributor Author

bdraco commented Mar 1, 2024

I enabled an old config entry on a test instance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue:backend For issues with the backend/integration
Projects
None yet
Development

No branches or pull requests

2 participants