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.38k stars 30.65k forks source link

Local Calendar - Unexpected exception importing platform homeassistant.components.local_calendar.calendar #93904

Closed jonathanathe closed 1 year ago

jonathanathe commented 1 year ago

The problem

When I updated today to Home Assistant 2023.6.0b1 the Local Calendar integration stopped working and I can't see my calendars and I can't create new ones.

What version of Home Assistant Core has the issue?

2023.6.0b1

What was the last working version of Home Assistant Core?

2023.5.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Local Calendar

Link to integration documentation on our website

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

Diagnostics information

Unexpected exception importing platform homeassistant.components.local_calendar.calendar
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 833, in get_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 850, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/local_calendar/calendar.py", line 9, in <module>
    from ical.calendar import Calendar
  File "/usr/local/lib/python3.11/site-packages/ical/calendar.py", line 14, in <module>
    from .event import Event
  File "/usr/local/lib/python3.11/site-packages/ical/event.py", line 58, in <module>
    class Event(ComponentModel):
  File "/usr/local/lib/python3.11/site-packages/ical/event.py", line 366, in Event
    @root_validator(pre=True)
     ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydantic/class_validators.py", line 129, in dec
    f_cls = _prepare_validator(f, allow_reuse)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydantic/class_validators.py", line 147, in _prepare_validator
    raise ConfigError(f'duplicate validator function "{ref}"; if this is intended, set `allow_reuse=True`')
pydantic.errors.ConfigError: duplicate validator function "ical.event.Event._inspect_date_types"; if this is intended, set `allow_reuse=True`

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

home-assistant[bot] commented 1 year ago

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

Code owner commands Code owners of `local_calendar` 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 local_calendar` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


local_calendar documentation local_calendar source (message by IssueLinks)

shbatm commented 1 year ago

Experiencing the same error. Still present in Beta 4.

Similar, but not exactly the same error in 2025.6.0b4

Logger: homeassistant.loader
Source: components/local_calendar/calendar.py:9
First occurred: 1:23:09 PM (1 occurrences)
Last logged: 1:23:09 PM

Unexpected exception importing platform homeassistant.components.local_calendar.calendar
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 833, in get_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 850, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/src/homeassistant/homeassistant/components/local_calendar/calendar.py", line 9, in <module>
    from ical.calendar import Calendar
  File "/usr/local/lib/python3.11/site-packages/ical/calendar.py", line 14, in <module>
    from .event import Event
  File "/usr/local/lib/python3.11/site-packages/ical/event.py", line 58, in <module>
    class Event(ComponentModel):
  File "/usr/local/lib/python3.11/site-packages/pydantic/main.py", line 292, in __new__
    cls.__signature__ = ClassAttribute('__signature__', generate_model_signature(cls.__init__, fields, config))
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pydantic/utils.py", line 258, in generate_model_signature
    merged_params[param_name] = Parameter(
                                ^^^^^^^^^^
  File "/usr/local/lib/python3.11/inspect.py", line 2722, in __init__
    raise ValueError('{!r} is not a valid parameter name'.format(name))
ValueError: 'class' is not a valid parameter name

config_entry-local_calendar-2c1d79d60144b5c15549f64d66468c69.json.txt

allenporter commented 1 year ago

@jonathanathe do you have diagnostics information for the integration? fwiw nothing changed in local calendar here as far as I know. This is difficult to diagnose. Also interesting there are two unrelated errors.

allenporter commented 1 year ago

e.g. the last change to ical was 3 months ago: https://github.com/home-assistant/core/commit/fa35867765cb38a39c0e07c6c34ad771a5dec112

Is there a way to know what version of pydantic folks are running here? This has been tested on 1.10.8 released a few weeks ago and also and it works fine on everything above 1.9.1 and below v2.

I am curious if there are other home assistant packages using pydantic that also see this.

allenporter commented 1 year ago

I'm wondering if ha core rebuild helps fix packages that are messed up?

firstof9 commented 1 year ago

config_entry-local_calendar-448b91024296ee3afde0968edb1512ef.json.txt

Here's my diagnostics @allenporter, I hope it helps. Running just container 2023.6.0b5

EDIT: pip freeze says:

pydantic==1.9.2
allenporter commented 1 year ago

FWIW the common custom components so far are:

  "frigate",
  "grocy",
  "hacs",
balloob commented 1 year ago

What version of ical?

allenporter commented 1 year ago

Both are using 4.5.1 of ical which is current. grocy uses pydantic fwiw, so maybe there is something going off there...

allenporter commented 1 year ago

Grocy hasn't updated for awhile though since 2022.

jonathanathe commented 1 year ago

ha core rebuild

Hi @allenporter, I did the test with ha core rebuild and it got it working again.

Thank you very much!

firstof9 commented 1 year ago

What would be the equivalent in a container install to ha core rebuild ?

shbatm commented 1 year ago

So a ha core rebuild didn't fix the issue, but when I subsequently updated from b4 to b6 the integration loaded fine.

🤷‍♂️

firstof9 commented 1 year ago

Still shows up in 2023.6.0 :frowning_face:

firstof9 commented 1 year ago

Found this https://github.com/tiangolo/fastapi/issues/5048#issuecomment-1229183881

Updating pydantic to 1.10.9 in my container worked.

balloob commented 1 year ago

We have a bump here https://github.com/home-assistant/core/pull/94178, i will tag it for the next patch release.

balloob commented 1 year ago

hm no, we only require it in HA for testing.

I wonder if we should add it to constraints @allenporter ?

firstof9 commented 1 year ago

:man_shrugging: all I can tell you is bumping it worked for me, I think it's a requirement in the grocy integration, likely need to open an issue there.

EDIT: it's not a requirement for the grocy 3rd party integration, :man_shrugging: