00 Internal Server Error when hit configure
Closed this issue ยท 19 comments
Describe the bug
When hit "Configure" in the integration page you get this error:
Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble
To Reproduce
- Go to Settings
- Click on Devices & Services
- Click on Alexa Media Player
- Click on Configure
Expected behavior
A screen to manage some settings
Screenshots
System details
HA:
Core 2024.7.2
Supervisor 2024.06.2
Operating System 12.4
Frontend 20240710.0
Integration:
alexa_media_player: 4.11.0
Logs
2024-07-18 12:44:36.325 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 "/config/custom_components/alexa_media/config_flow.py", line 877, in async_step_init
default=self.config_entry.data[CONF_QUEUE_DELAY],
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
KeyError: 'queue_delay'
Same here....
I have the same issue since updating to the latest version.
'Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble'
Same here....
Same
same
same
Bumping, same issue here. Tried to update to fix an issue with my light status not updating when I hit the switch
I have the same error
@danielbrunt57 probably need to use a get with default values. Thanks.
The errors are not tied to the translations file. It's related to default settings and trying to pull a default settings that doesn't exist. Hence the need to use a dictionary get.
Once there's a new release, the translations will update appropriately based on whatever works translators have done since the new keys were entered.
The errors are not tied to the translations file.
I understand that.
It's related to default settings and trying to pull a default settings that doesn't exist. Hence the need to use a dictionary get.
I'm not seeing that on my system...
Re: "KeyError: 'queue_delay'"
I believe the issue stems from the fact that you all had an older version installed which created an entry in core.config_entries without the "queue_delay" setting in it. After upgrading, the new code sees there is an existing entry and proceeds assuming all the new data fields are there. Alan's response I think is then correct albeit somewhat incomplete for me as a novice developer as I was looking at it as a new installation and forgot to factor this upgrade scenario into the mix. I'll need some time to get my head inside the code again and figure out how to implement Alan's comment. If you can't wait, then a re&re of the integration in HA should setup a new config entry correctly. Or if you prefer, you can edit config/.storage/core.config_entries adding in the missing keys/fields & restarting HA.
{
"data": {
"url": "amazon.com",
"otp_secret": "A*7*T*Y*Y*U*U*M*4*M*F*A*5*X*E*C*N*Z*P*C*F*2*H*M*T*4*A",
"email": "******@******",
"password": "******",
"scan_interval": 60,
"queue_delay": 1.5,
"include_devices": "",
"exclude_devices": "",
"extended_entity_discovery": false,
"debug": false,
"oauth": {
"access_token": "**************************************************************************
"refresh_token": "**************************************************************************
"expires_in": 1234567890.123456,
"mac_dms": {
"device_private_key": "**************************************************************************
"adp_token": "{enc:**************************************************************************
},
"code_verifier": "************************************************************",
"authorization_code": "A*C*g*Z*q*X*g*P*t*z*L*o*"
}
},
"disabled_by": null,
"domain": "alexa_media",
"entry_id": "0*J*5*E*M*H*J*8*5*S*0*1*X",
"minor_version": 1,
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "user",
"title": "******@****** - amazon.com",
"unique_id": "******@****** - amazon.com",
"version": 1
}
doesn't work here. Then its missing extended_entity_discovery
When add this one and restart HA its gone after the restart
So, I've removed everything, reinstalled official 4.11.0 and it works fine for me (except the options flow descriptions)...
queue_delay is saved and retrieved from config just fine,
I have the same now after a complete remove of the addon through Hacs then reinstall of the latest version, restart HA and reconfigure login credentials. All my devices came back in with the same names and all my automations with notifications work again.
Same here
same
Yes, a re&re solves the issue of the missing queue_delay in previously configured setups. I'm still trying to figure out how to code it so a re&re is not necessary.
The missing descriptions will self-rectify once there's a new release as the translations will update appropriately based on whatever work translators have done since the new keys were entered.
Nailed it, finally!
Existing config_entry - core.config_entries:
{
"data": {
"url": "amazon.com",
"otp_secret": ""...................................................................................................",
"email": "me@my.domain",
"password": "<password>",
"scan_interval": 60,
"include_devices": "",
"exclude_devices": "",
"oauth": {
"access_token": "".........................................................................................................................................................
"refresh_token": "".........................................................................................................................................................
"expires_in": 1721457166.751123,
"mac_dms": {
"device_private_key": "".........................................................................................................................................................
"adp_token": "{enc:".........................................................................................................................................................
},
"code_verifier": ""................................................................................................................",
"authorization_code": "..............................................."
}
},
"disabled_by": null,
"domain": "alexa_media",
"entry_id": "01J3790YAE1QAP38VCM3GKRRY3",
"minor_version": 1,
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "user",
"title": "me@my.domain- amazon.com",
"unique_id": "me@my.domain- amazon.com",
"version": 1
}
Configure options window:
After editing:
New config_entry - core.config_entries:
{
"data": {
"scan_interval": 0,
"queue_delay": 1.5,
"extended_entity_discovery": false,
"debug": true,
"include_devices": "",
"exclude_devices": "",
"url": "amazon.com",
"email": "me@my.domain",
"password": "<password>",
"otp_secret": " ",
"oauth": {
"access_token": ".........................................................................................................................................................
"refresh_token": "".........................................................................................................................................................
"expires_in": 1721457166.751123,
"mac_dms": {
"device_private_key": "".........................................................................................................................................................
"adp_token": "{enc:".........................................................................................................................................................
},
"code_verifier": "....................................................................................................",
"authorization_code": "................................................."
}
},
"disabled_by": null,
"domain": "alexa_media",
"entry_id": "01J3790YAE1QAP38VCM3GKRRY3",
"minor_version": 1,
"options": {},
"pref_disable_new_entities": false,
"pref_disable_polling": false,
"source": "user",
"title": "me@my.domain- amazon.com",
"unique_id": "me@my.domain- amazon.com",
"version": 1
}
Now to review/cleanup my work and submit a PR...