bruxy70/Holidays

Installation fails - Unknown error occurred

Closed this issue · 13 comments

Before you submit a new bug report, please check that

Describe the bug

Installed the repository from HACS.
Attempted to +Add Integration with the following values:
Friendly Name: Canadian
Icon: mdi:calendar-blank
Icon collection today: mdi:calendar-arrow-right
Icon collection tomorrow: mdi:calendar-check
Country: CA
[X] Observed (optional)

Clicking SUBMIT yields a red box with: (!) Unknown error occurred

Configuration

Integration never installs.  I cannot submit Configuration

Debug logs

This error originated from a custom integration.

Logger: aiohttp.server
Source: custom_components/holidays/config_flow.py:109
Integration: Holidays (documentation, issues)
First occurred: 13:21:40 (2 occurrences)
Last logged: 13:21:54

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 219, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 205, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 109, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 260, in async_configure
    result = await self._async_handle_step(
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 335, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/holidays/config_flow.py", line 167, in async_step_user
    return await self.async_step_subdiv(re_entry=False)
  File "/config/custom_components/holidays/config_flow.py", line 185, in async_step_subdiv
    self.shared_class.step2_subdiv(user_input)
  File "/config/custom_components/holidays/config_flow.py", line 109, in step2_subdiv
    subdivs = self._supported_countries[self._data.get(const.CONF_COUNTRY)]
TypeError: list indices must be integers or slices, not str

Tried to replicate it, the integration has installed with no problem (showing a public holiday on Monday this week).

I have the same issue trying to install it. It just won't go to second screen after clicking submit. The log shows the same as DaveYYZ.

I am thinking you might have an older version of the holidays python package. What version is HA do you have?

Said that, HACS checks the minimal HA version, that comes with the proper holidays version. So I do not know how that could happen....

I have the latest version core-2022.5.5 and Home Assistant OS 8.1.

I just ran into this same problem.

I am rumming it as a VM

I have removed the integration completely, reinstalled it, and it installed and configured (Canada) without issues. The unit test works fine as well (it just installs the HA and requirements and runs rests). So this has to do something with some specific configs.

It looks like for some reason, you have an older version of the holidays package. In the current version the list of supported countries is a dictionary (def list_supported_countries() -> Dict[str, List[str]]:). But until 0.12 it was a list (def list_supported_countries() -> List[str]:), . And the list included duplicate entries for each country so this was useless.

This is why it complains when I ask for the list of territories by calling supported_countries[name of the country], it complains, as it expects a list, not a dictionary (so it would expect somehing like supported_countries[integer] - but even that would be useless as that did not contain the territries anyhow - they had different parameters for different countries, for some it was states, for others it was...I do not know what anymore). So this was a breaking change.

In the requirements, there is holidays>=0.13. Yet, for some reason, you probably have an older version.
For the same reason, there is a minimal HA version, as HA used the same package for the workday sensor, From 2022.5.0 it is 0.13.
Yet, for some reason I do not understand, you probably have an old holidays package.

I didn't have holidays installed prior to the error. This is a new install, so the older version had to come from HACS, since this is where I installed it from.

My installed Holidays version is release v1.7.4

Right, i refer to the python package https://pypi.org/project/holidays/
This integration does not calculate any holidays on its own. It is just using this package. I know it is confusing, i should have probably given it a different name :)

Please check the latest release. It updates the requirements for the latest holidays package. The same version is now used by HomeAssistant's workday.