bruxy70 / Holidays

📅 Custom Home Assistant integration for public holidays - also used for garbage_collection integration to automatically move scheduled events that fall on a public holiday (by an automation blueprint)
MIT License
45 stars 12 forks source link

Installation fails - Unknown error occurred #32

Closed DaveYYZ closed 2 years ago

DaveYYZ commented 2 years ago

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
bruxy70 commented 2 years ago

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

DaveYYZ commented 2 years ago

Must be something unique to my setup. I've tried many times - with different countries, restarting, etc.. always the same undefined error 🙁

Doesn't look like anyone else has had the problem.

Dave.


From: Vaclav @.> Sent: Wednesday, May 25, 2022 15:18 To: bruxy70/Holidays @.> Cc: DaveYYZ @.>; Author @.> Subject: Re: [bruxy70/Holidays] Installation fails - Unknown error occurred (Issue #32)

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

— Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fbruxy70%2FHolidays%2Fissues%2F32%23issuecomment-1137759233&data=05%7C01%7C%7C0927fe2974dd48437b6608da3e836b8a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637891031416968649%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=TSOjP%2BxTqRrXX9MdaqhwwV8LIkRgoCQJSHtb%2FbrjygU%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FATX6YU624VE66EPA7LU7XOLVLZ4KFANCNFSM5W6DZ7PQ&data=05%7C01%7C%7C0927fe2974dd48437b6608da3e836b8a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637891031416968649%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=J2avN4Tt%2BNGoJGIoWkOfmh6VpnpdbDI9ij6fmU77Vto%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>

jrrcor commented 2 years ago

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.

bruxy70 commented 2 years ago

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

bruxy70 commented 2 years ago

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

jrrcor commented 2 years ago

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

snadboy commented 2 years ago

I just ran into this same problem.

DaveYYZ commented 2 years ago

To those of us who’ve had a failed install; what platform are you running HA on? I’m on the Blue box.

Get Outlook for iOShttps://aka.ms/o0ukef


From: snadboy @.> Sent: Saturday, June 11, 2022 3:06:59 PM To: bruxy70/Holidays @.> Cc: DaveYYZ @.>; Author @.> Subject: Re: [bruxy70/Holidays] Installation fails - Unknown error occurred (Issue #32)

I just ran into this same problem.

— Reply to this email directly, view it on GitHubhttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fbruxy70%2FHolidays%2Fissues%2F32%23issuecomment-1152983122&data=05%7C01%7C%7Cca86056f48904b04d32e08da4bdd9019%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637905712222848363%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=sUtzvX1V2fdlv8Dx20KxDtnO4SCX7lTYcwEsfopN0SY%3D&reserved=0, or unsubscribehttps://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FATX6YU3E5PHOXI64ZM43ID3VOTPVHANCNFSM5W6DZ7PQ&data=05%7C01%7C%7Cca86056f48904b04d32e08da4bdd9019%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637905712223005032%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=XV3IvjfuVOD28bjZvv0fwJQGJplLYzsGrHsvi6txX2o%3D&reserved=0. You are receiving this because you authored the thread.Message ID: @.***>

jrrcor commented 2 years ago

I am rumming it as a VM

bruxy70 commented 2 years ago

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.

jrrcor commented 2 years ago

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

bruxy70 commented 2 years ago

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 :)

bruxy70 commented 2 years ago

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