Skip to content

Remote Calendar not accepting invalid Google Calendar ics content - can't compare offset-naive and offset-aware datetimes #142212

Open
@ivanfmartinez

Description

@ivanfmartinez

The problem

Trying to use my existing google calendar on new remote_calendar integration the calendar is not loaded.

From the user perspective if they cant parse a single entry it should continue to others and give warning about the problem, not skip the entire calendar.

The log does not indicate URL, just the entity_id and after the calendar is configured the URL are not visible anymore on HA WEB UI.

What version of Home Assistant Core has the issue?

core-2025.4.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

remote_calendar

Link to integration documentation on our website

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

Diagnostics information

No response

Example YAML snippet

Anything in the logs that might be useful for us?

2025-04-03 13:45:02.963 INFO (MainThread) [homeassistant.components.calendar] Setting up remote_calendar.calendar
2025-04-03 13:45:02.965 ERROR (MainThread) [homeassistant.components.calendar] Error adding entity calendar.compromissos for domain calendar with platform remote_calendar
Traceback (most recent call last):
  File "/usr/local/lib/python3.13/site-packages/ical/iter.py", line 190, in __iter__
    for value in self._ruleset():
                 ~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/dateutil/rrule.py", line 1401, in _iter
    while exlist and exlist[0] < ritem:
                     ^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/dateutil/rrule.py", line 1338, in __lt__
    return self.dt < other.dt
           ^^^^^^^^^^^^^^^^^^
TypeError: can't compare offset-naive and offset-aware datetimes

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

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 633, in _async_add_entities
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 972, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1384, in add_to_platform_finish
    self.async_write_ha_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/components/calendar/__init__.py", line 563, in async_write_ha_state
    super().async_write_ha_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1023, in async_write_ha_state
    self._async_write_ha_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1148, in _async_write_ha_state
    self.__async_calculate_state()
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1085, in __async_calculate_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1029, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/calendar/__init__.py", line 546, in state
    if (event := self.event) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/remote_calendar/calendar.py", line 57, in event
    if event := next(events, None):
                ~~~~^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/ical/iter.py", line 369, in active_after
    for item in self._iterable:
                ^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/ical/iter.py", line 252, in __next__
    self._make_heap()
    ~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/ical/iter.py", line 242, in _make_heap
    next_item = next(iterator)
  File "/usr/local/lib/python3.13/site-packages/ical/iter.py", line 222, in __iter__
    for dtvalue in self._recur:
                   ^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/ical/iter.py", line 193, in __iter__
    raise RecurrenceError(
        f"Error evaluating recurrence rule ({self}): {str(err)}"
    ) from err
ical.exceptions.RecurrenceError: Error evaluating recurrence rule (RulesetIterable(dtstart=2003-02-03 17:00:00-03:00, rrule=['DTSTART:20030203T170000\nRRULE:FREQ=DAILY;UNTIL=20030213T160000'], rdate=[], exdate=[datetime.datetime(2003, 2, 8, 17, 0), datetime.datetime(2003, 2, 9, 17, 0)])): can't compare offset-naive and offset-aware datetimes

Additional information

The only event that matches the indicated RRULE on the logs is this and have TZID indication that are not show on the log

BEGIN:VEVENT
DTSTART;TZID=America/Argentina/Buenos_Aires:20030203T170000
DTEND;TZID=America/Argentina/Buenos_Aires:20030203T190000
RRULE:FREQ=DAILY;UNTIL=20030213T160000Z
EXDATE;VALUE=DATE:20030208
EXDATE;VALUE=DATE:20030209
DTSTAMP:20250403T173533Z
UID:REDACTED
CLASS:PUBLIC
CREATED:20060315T210421Z
LAST-MODIFIED:20230220T034045Z
SEQUENCE:3
STATUS:TENTATIVE
SUMMARY:REDACTED
TRANSP:OPAQUE
END:VEVENT

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions