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
73.28k stars 30.6k forks source link

[Unifi] If url returns 403 the extension can't be reconfigured. #122560

Closed raldone01 closed 3 months ago

raldone01 commented 3 months ago

The problem

I misconfigured the unifi extension to use an incorrect url which returns 403. When I click configure it throws an exception and I can't change any settings.

I have not done a deep inspection of the exception. But I assume it is because of the 403.

What version of Home Assistant Core has the issue?

core-2024.7.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

Unifi

Link to integration documentation on our website

https://www.home-assistant.io/integrations/unifi/

Diagnostics information

home-assistant_unifi_2024-07-24T20-44-32.508Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2024-07-24 22:35:36.592 ERROR (MainThread) [homeassistant.components.unifi] Error connecting to the UniFi Network at unifi.redacted.com: Call https://unifi.redacted.com:443 received 403 Forbidden
2024-07-24 22:36:13.498 ERROR (MainThread) [homeassistant.components.unifi] Error connecting to the UniFi Network at unifi.redacted.com: Call https://unifi.redacted.com:443 received 403 Forbidden
2024-07-24 22:36:16.634 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 210, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 262, in post
    return await super().post(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 74, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 77, in post
    return await self._post_impl(request, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 84, in _post_impl
    result = await self._flow_mgr.async_init(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 343, in async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 518, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/unifi/config_flow.py", line 263, in async_step_init
    self.hub = self.config_entry.runtime_data
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ConfigEntry' object has no attribute 'runtime_data'
2024-07-24 22:36:18.871 ERROR (MainThread) [homeassistant.components.unifi] Error connecting to the UniFi Network at unifi.redacted.com: Call https://unifi.redacted.com:443 received 403 Forbidden
2024-07-24 22:36:29.256 ERROR (MainThread) [homeassistant.components.unifi] Error connecting to the UniFi Network at unifi.redacted.com: Call https://unifi.redacted.com:443 received 403 Forbidden
2024-07-24 22:36:49.436 ERROR (MainThread) [homeassistant.components.unifi] Error connecting to the UniFi Network at unifi.redacted.com: Call https://unifi.redacted.com:443 received 403 Forbidden
2024-07-24 22:37:29.646 ERROR (MainThread) [homeassistant.components.unifi] Error connecting to the UniFi Network at unifi.redacted.com: Call https://unifi.redacted.com:443 received 403 Forbidden
2024-07-24 22:38:49.934 ERROR (MainThread) [homeassistant.components.unifi] Error connecting to the UniFi Network at unifi.redacted.com: Call https://unifi.redacted.com:443 received 403 Forbidden


### Additional information

_No response_
home-assistant[bot] commented 3 months ago

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

Code owner commands Code owners of `unifi` 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 unifi` 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)


unifi documentation unifi source (message by IssueLinks)

Kane610 commented 3 months ago

Running the configure step triggers the options flow which only works on loaded integrations. The options flow does not help you with reconfiguring addresses. I recommend you remove the integration and set it up a new

raldone01 commented 3 months ago

I did not want to set it up again so I temporarily made the unifi-controller available under that url and triggered the reauth process by changing the password of the user.

The reauth process allows the user to change all instance settings. It would be cool if there was a way to manually trigger the rauth if requests to the controller fail.

Kane610 commented 3 months ago

The reauth process allows the user to change all instance settings. I would be cool if there was a way to manually trigger the rauth if requests to the controller fail.

There is but its not yet implemented on the unifi integration

raldone01 commented 3 months ago

Nice. Is the reauth anytime a homeassistant core feature? Can you link me to the relevant documentation?