Gracefully handle caldav event with missing summary (#84719)

fixes undefined
This commit is contained in:
Allen Porter 2022-12-28 13:07:51 -08:00 committed by GitHub
parent 580f2058a7
commit 128ccbaa57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 3 deletions

View File

@ -184,7 +184,7 @@ class WebDavCalendarData:
continue continue
event_list.append( event_list.append(
CalendarEvent( CalendarEvent(
summary=vevent.summary.value, summary=self.get_attr_value(vevent, "summary") or "",
start=vevent.dtstart.value, start=vevent.dtstart.value,
end=self.get_end_date(vevent), end=self.get_end_date(vevent),
location=self.get_attr_value(vevent, "location"), location=self.get_attr_value(vevent, "location"),
@ -264,7 +264,9 @@ class WebDavCalendarData:
return return
# Populate the entity attributes with the event values # 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( self.event = CalendarEvent(
summary=summary, summary=summary,
start=vevent.dtstart.value, start=vevent.dtstart.value,

View File

@ -214,6 +214,18 @@ DESCRIPTION:The bell tolls for thee
RRULE:FREQ=HOURLY;INTERVAL=1;COUNT=12 RRULE:FREQ=HOURLY;INTERVAL=1;COUNT=12
END:VEVENT END:VEVENT
END:VCALENDAR 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() await hass.async_block_till_done()
events = await get_api_events("calendar.private") events = await get_api_events("calendar.private")
assert len(events) == 14 assert len(events) == 15
assert calendar.call assert calendar.call