dvd-dev/hilo

Unknown error occurred when trying to login while adding the integration

gauvingingras opened this issue · 13 comments

Version of the custom_component

v2023.10.1

Configuration

Configured through the UI flow

Describe the bug

Whenever I try to add the integration through the web UI, I get an unknown exception even if my username and password are properly set.

Debug log


2023-10-27 09:25:45 2023-10-27 09:25:45.586 ERROR (MainThread) [aiohttp.server] Error handling request
2023-10-27 09:25:45 Traceback (most recent call last):
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
2023-10-27 09:25:45     resp = await request_handler(request)
2023-10-27 09:25:45            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
2023-10-27 09:25:45     resp = await handler(request)
2023-10-27 09:25:45            ^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
2023-10-27 09:25:45     return await handler(request)
2023-10-27 09:25:45            ^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
2023-10-27 09:25:45     return await handler(request)
2023-10-27 09:25:45            ^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
2023-10-27 09:25:45     return await handler(request)
2023-10-27 09:25:45            ^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
2023-10-27 09:25:45     return await handler(request)
2023-10-27 09:25:45            ^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/ban.py", line 80, in ban_middleware
2023-10-27 09:25:45     return await handler(request)
2023-10-27 09:25:45            ^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/auth.py", line 236, in auth_middleware
2023-10-27 09:25:45     return await handler(request)
2023-10-27 09:25:45            ^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/headers.py", line 31, in headers_middleware
2023-10-27 09:25:45     response = await handler(request)
2023-10-27 09:25:45                ^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/view.py", line 148, in handle
2023-10-27 09:25:45     result = await handler(request, **request.match_info)
2023-10-27 09:25:45              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/decorators.py", line 63, in with_admin
2023-10-27 09:25:45     return await func(self, request, *args, **kwargs)
2023-10-27 09:25:45            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/config/config_entries.py", line 177, in post
2023-10-27 09:25:45     return await super().post(request, flow_id)
2023-10-27 09:25:45            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/data_validator.py", line 72, in wrapper
2023-10-27 09:25:45     result = await method(view, request, data, *args, **kwargs)
2023-10-27 09:25:45              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/data_entry_flow.py", line 110, in post
2023-10-27 09:25:45     result = await self._flow_mgr.async_configure(flow_id, data)
2023-10-27 09:25:45              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/data_entry_flow.py", line 293, in async_configure
2023-10-27 09:25:45     result = await self._async_handle_step(
2023-10-27 09:25:45              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/lsiopy/lib/python3.11/site-packages/homeassistant/data_entry_flow.py", line 394, in _async_handle_step
2023-10-27 09:25:45     result: FlowResult = await getattr(flow, method)(user_input)
2023-10-27 09:25:45                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/config/custom_components/hilo/config_flow.py", line 149, in async_step_user
2023-10-27 09:25:45     hilo = await API.async_auth_password(
2023-10-27 09:25:45            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45   File "/config/lsiopy/lib/python3.11/site-packages/pyhilo/api.py", line 172, in async_auth_password
2023-10-27 09:25:45     await api.async_auth_post(auth_body)
2023-10-27 09:25:45   File "/config/lsiopy/lib/python3.11/site-packages/pyhilo/api.py", line 290, in async_auth_post
2023-10-27 09:25:45     set_state(self._state_yaml, "token", token_dict)
2023-10-27 09:25:45   File "/config/lsiopy/lib/python3.11/site-packages/pyhilo/util/state.py", line 107, in set_state
2023-10-27 09:25:45     with open(state_yaml, "w") as yaml_file:
2023-10-27 09:25:45          ^^^^^^^^^^^^^^^^^^^^^
2023-10-27 09:25:45 PermissionError: [Errno 13] Permission denied: 'hilo_state.yaml'

Est-ce que HASS a accès en écriture à /custom_component?

Ça semble être un problème de permissions à première vue.

C'est ça les droits pour les folders custom_components et hilo sur mon installation, je semble avoir les droits?

image
image
image

Heille je m’excuse j’étais dans les patates. Le fichier hilo_state.yaml va se créer sous /config

C’est là que je vérifierais les permissions.

Mon erreur!

Dans mon fichier docker_compose.yml, le folder /config de HomeAssistant est mappé sur ce folder la, qui semble avoir les bonnes permissions:

image
image

Même quand je le créé manuellement (fichier vide avec le bon nom) et que j'essais la configuration après un reboot, ça change rien, toujours la même erreur:

image


Logger: aiohttp.server
Source: .local/lib/python3.10/site-packages/pyhilo/util/state.py:107
First occurred: 4:09:17 PM (1 occurrences)
Last logged: 4:09:17 PM

Error handling request
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/lib/python3.10/site-packages/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/lib/python3.10/site-packages/homeassistant/data_entry_flow.py", line 271, in async_configure
    result = await self._async_handle_step(
  File "/usr/lib/python3.10/site-packages/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/hilo/config_flow.py", line 149, in async_step_user
    hilo = await API.async_auth_password(
  File "/config/.local/lib/python3.10/site-packages/pyhilo/api.py", line 172, in async_auth_password
    await api.async_auth_post(auth_body)
  File "/config/.local/lib/python3.10/site-packages/pyhilo/api.py", line 290, in async_auth_post
    set_state(self._state_yaml, "token", token_dict)
  File "/config/.local/lib/python3.10/site-packages/pyhilo/util/state.py", line 107, in set_state
    with open(state_yaml, "w") as yaml_file:
PermissionError: [Errno 13] Permission denied: 'hilo_state.yaml'

Voici les miennes
Screen Shot 2023-10-27 at 4 21 26 PM

Screen Shot 2023-10-27 at 4 23 09 PM

J'essayerais un reboot de HA aussi, je semble avoir perdu la connexion avec les serveurs il y a de ça 3h environ...

J'ai essayé avec les mêmes permissions que toi, avec et sans le fichier existant, rien ne change. Le log reste le même:

image
image


Logger: aiohttp.server
Source: .local/lib/python3.10/site-packages/pyhilo/util/state.py:107
First occurred: 4:40:19 PM (1 occurrences)
Last logged: 4:40:19 PM

Error handling request
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
  File "/usr/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/auth.py", line 235, in auth_middleware
    return await handler(request)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/view.py", line 146, in handle
    result = await result
  File "/usr/lib/python3.10/site-packages/homeassistant/components/config/config_entries.py", line 180, in post
    return await super().post(request, flow_id)
  File "/usr/lib/python3.10/site-packages/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
  File "/usr/lib/python3.10/site-packages/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/lib/python3.10/site-packages/homeassistant/data_entry_flow.py", line 271, in async_configure
    result = await self._async_handle_step(
  File "/usr/lib/python3.10/site-packages/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/hilo/config_flow.py", line 149, in async_step_user
    hilo = await API.async_auth_password(
  File "/config/.local/lib/python3.10/site-packages/pyhilo/api.py", line 172, in async_auth_password
    await api.async_auth_post(auth_body)
  File "/config/.local/lib/python3.10/site-packages/pyhilo/api.py", line 290, in async_auth_post
    set_state(self._state_yaml, "token", token_dict)
  File "/config/.local/lib/python3.10/site-packages/pyhilo/util/state.py", line 107, in set_state
    with open(state_yaml, "w") as yaml_file:
PermissionError: [Errno 13] Permission denied: 'hilo_state.yaml'

Fait intéressant, quand j'essaie avec un mauvais mot de passe, l'erreur semble indiquer bad login, donc on dirait en effet un problème de permissions pour le fichier, mais elles sont identiques...


Logger: pyhilo
Source: .local/lib/python3.10/site-packages/pyhilo/api.py:172
First occurred: 4:40:29 PM (2 occurrences)
Last logged: 4:40:29 PM

ClientResponseError: 400, message='Bad Request', url=URL('https://hilodirectoryb2c.b2clogin.com/hilodirectoryb2c.onmicrosoft.com/oauth2/v2.0/token?p=B2C_1A_B2C_1_PasswordFlow')
Raising InvalidCredentialsError from 400, message='Bad Request', url=URL('https://hilodirectoryb2c.b2clogin.com/hilodirectoryb2c.onmicrosoft.com/oauth2/v2.0/token?p=B2C_1A_B2C_1_PasswordFlow')

Je suis pas le créateur alors prendre ça avec un grain de sel, mais le yaml contient ton token de login(donc un login réussi), c’est pour ça que tu as une 400 en te trompant sans erreur de yaml.

C’est niaiseux mais peux-tu essayer un clean install de Hilo? Ça a déjà fixé des troubles semblable dans le passé.

le yaml contient ton token de login(donc un login réussi), c’est pour ça que tu as une 400 en te trompant sans erreur de yaml.

This.

Ensuite, les permissions que tu vois dans le screenshot sont relatives à ton host tandis que l'erreur vient du container.

Quel est l'host du container? Si c'est Fedora/CentOS, c'est possible que ça soit un problème avec SELinux, sinon tu peux toujours essayé de changer les permissions pour que soit "world writable" (chmod 0666 hilo_state.yaml).

Les mots de passes Hilo qui ont des caractères spéciaux ne fonctionne pas. Essayer avec un mot de passe avec des lettres et des chiffres.

Les mots de passes Hilo qui ont des caractères spéciaux ne fonctionne pas. Essayer avec un mot de passe avec des lettres et des chiffres.

Plusieurs caractères spéciaux étaient permis mais le "+" n'en était pas un. Je viens de l'ajouter.

@gauvingingras as-tu pu réssayer depuis le dernier release?¸

Ah m’y bad, j’ai complètement oublié de venir updater ici! Oui, ça fonctionne très bien maintenant, c’était effectivement un problème de permission qui a été réglé grâce aux interventions précédentes.

depuis, j’ai aussi changé mon setup pour utiliser Home Assistant Supervised (HassOS) et ça fonctionne aussi très bien.

merci du support!