franc6 / ics_calendar

Provides an ICS (icalendar) platform for the Home Assistant calendar
Apache License 2.0
149 stars 22 forks source link

async_get_events: Spaldo: Failed to parse ICS! #180

Open DrSpaldo opened 1 week ago

DrSpaldo commented 1 week ago

Home Assistant Setup Please indicate your version of HA and how it is installed.

Version: 2024.9.3 & 2024.10.2

Installation Type (put an X between the square brackets for your HA): [] Home Assistant OS [] Home Assistant OS [] Home Assistant Supervised [x] Home Assistant Container [] Home Assistant Core

Hardware platform: [] ARM [x] x86-64

Describe the bug All of a sudden, my ics calendar isn't downloading. Google private calendar link in ical. So I have tried two versions of HA and three versions of this (5.0.2 5.0.3 & 5.0.4 beta). All will not download the calendar anymore and gives me the following error in the logs:

This error originated from a custom integration.

Logger: custom_components.ics_calendar.calendar
Source: custom_components/ics_calendar/calendar.py:304
integration: ics Calendar (documentation, issues)
First occurred: 9:50:30 am (37 occurrences)
Last logged: 1:31:14 pm

async_get_events: Spaldo1: Failed to parse ICS!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/calendar/__init__.py", line 386, in __post_init__
    CALENDAR_EVENT_SCHEMA(dataclasses.asdict(self, dict_factory=skip_none))
  File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 205, in __call__
    return self._compiled([], data)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/voluptuous/validators.py", line 256, in _run
    return self._exec(self._compiled, value, path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/voluptuous/validators.py", line 386, in _exec
    raise e if self.msg is None else AllInvalid(self.msg, path=path)
  File "/usr/local/lib/python3.12/site-packages/voluptuous/validators.py", line 384, in _exec
    v = func(path, v)
        ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 549, in validate_dict
    return base_validate(path, data.items(), out)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/voluptuous/schema_builder.py", line 382, in validate_mapping
    raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: required key not provided @ data['summary']

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/config/custom_components/ics_calendar/calendar.py", line 304, in async_get_events
    event_list = self.parser.get_event_list(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/ics_calendar/parsers/parser_rie.py", line 77, in get_event_list
    calendar_event: CalendarEvent = CalendarEvent(
                                    ^^^^^^^^^^^^^^
  File "<string>", line 11, in __init__
  File "/usr/src/homeassistant/homeassistant/components/calendar/__init__.py", line 388, in __post_init__
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Failed to validate CalendarEvent: required key not provided @ data['summary']
DrSpaldo commented 1 week ago

Turns out it was because someone added an event without any title. I think it relates to this issue https://github.com/franc6/ics_calendar/issues/125

Would it be possible, that instead of the whole parser not working & just throwing an error, that if the event was say blank, it said "Unknown" or similar and didn't stop the integration from not working?

franc6 commented 1 week ago

I’m sorry, I should have replied earlier, but didn’t have the time to look up the previously reported issue. Really, I think the problem is in HA. Why not let users have calendar entries without a summary? Other calendars obviously allow it…

I’ve only gotten three opinions now on how to handle it, I think, and two of those were from the same person. :)

I need to do some testing still on what exactly is required, too. But so far, configurable might be the way to go, or perhaps the first X characters of the detail.

DrSpaldo commented 1 week ago

Thanks for the reply @franc6. When it wasn't working and I wasn't sure why, I tried this integration instead; https://github.com/tybritten/ical-sensor-homeassistant it handled the blank calendar entry by just saying "Unknown"

Either way, I agree it should allow it but I guess it ends up landing on you to do a work around. If possible, it would be appreciated...