python-o365 icon indicating copy to clipboard operation
python-o365 copied to clipboard

Calendar - Reading shared events, specifically a private event

Open topcats opened this issue 3 years ago • 3 comments

I have come across a problem when using a shared maibox calendar.

it was working fine, then the user added a 'private event'

The private event only emails very limited information (generally date and time only) to other users.

This then causes an issue when trying to read 'body' as it does not exist in the json

File "/home/pi/dashdisplay/app_calendar.py", line 214, in process
    for o365_event in o365_mycalendarEvents:
  File "/usr/local/lib/python3.7/dist-packages/O365/calendar.py", line 1765, in <genexpr>
    for event in data.get('value', []))
  File "/usr/local/lib/python3.7/dist-packages/O365/calendar.py", line 847, in __init__
    self.__body = body.get(cc('content'), '')
AttributeError: 'NoneType' object has no attribute 'get'

I'm not sure which other 'standard' loaded values are missing from the json, i have not got past this yet.

topcats avatar Oct 05 '21 16:10 topcats

The previous line is: body = cloud_data.get(cc('body'), {})

So if there's no body in the json, then body should be an empty dict. I don't understand right now how body ends up being None...

Nontheless maybe we should protect like this:

body = cloud_data.get(cc('body'), {})

body = body or {}  # <= protect agains body being None

self.__body = body.get(cc('content'), '')
self.body_type = body.get(cc('contentType'), 'HTML')  # default to HTML for new messages

alejcas avatar Oct 11 '21 07:10 alejcas

looks like a good fix I have no idea what other 'standard' fields might be returned invalid/different

topcats avatar Oct 13 '21 18:10 topcats

I’ll commit soon this fix

alejcas avatar Oct 14 '21 12:10 alejcas