From 128ccbaa5758b00076d9e588cb3a798f7ec28f28 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Wed, 28 Dec 2022 13:07:51 -0800 Subject: [PATCH] Gracefully handle caldav event with missing summary (#84719) fixes undefined --- homeassistant/components/caldav/calendar.py | 6 ++++-- tests/components/caldav/test_calendar.py | 14 +++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/caldav/calendar.py b/homeassistant/components/caldav/calendar.py index d510c0c08e7..2d5c7217043 100644 --- a/homeassistant/components/caldav/calendar.py +++ b/homeassistant/components/caldav/calendar.py @@ -184,7 +184,7 @@ class WebDavCalendarData: continue event_list.append( CalendarEvent( - summary=vevent.summary.value, + summary=self.get_attr_value(vevent, "summary") or "", start=vevent.dtstart.value, end=self.get_end_date(vevent), location=self.get_attr_value(vevent, "location"), @@ -264,7 +264,9 @@ class WebDavCalendarData: return # Populate the entity attributes with the event values - (summary, offset) = extract_offset(vevent.summary.value, OFFSET) + (summary, offset) = extract_offset( + self.get_attr_value(vevent, "summary") or "", OFFSET + ) self.event = CalendarEvent( summary=summary, start=vevent.dtstart.value, diff --git a/tests/components/caldav/test_calendar.py b/tests/components/caldav/test_calendar.py index b936a02db87..e9c58034cbe 100644 --- a/tests/components/caldav/test_calendar.py +++ b/tests/components/caldav/test_calendar.py @@ -214,6 +214,18 @@ DESCRIPTION:The bell tolls for thee RRULE:FREQ=HOURLY;INTERVAL=1;COUNT=12 END:VEVENT END:VCALENDAR +""", + """BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//Global Corp.//CalDAV Client//EN +BEGIN:VEVENT +UID:14 +DTSTAMP:20151125T000000Z +DTSTART:20151127T000000Z +DTEND:20151127T003000Z +RRULE:FREQ=HOURLY;INTERVAL=1;COUNT=12 +END:VEVENT +END:VCALENDAR """, ] @@ -917,7 +929,7 @@ async def test_get_events(hass, calendar, get_api_events): await hass.async_block_till_done() events = await get_api_events("calendar.private") - assert len(events) == 14 + assert len(events) == 15 assert calendar.call