ICS with multiple "STATUS" fields aren't handled correctly
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.1k
- Forks
- 233
- Avg merge
- 1h 44m
- Merged PRs (30d)
- 1
Description
Some Calendar tools, create ICS objects of invitations with multiple Status fields. This seems for me to happen on Kopano, when I change a reccurring invitation Item to not be recurring anymore for one day. (A.e. recurring daily meeting is rescheduled to a later point in the day).
This looks like this:
~ grep STATUS .calendars/Calendar/040000008200E00074xxxxxx9743BD251B5C9FBD.ics
STATUS:CONFIRMED
STATUS:CONFIRMED
STATUS:CONFIRMED
When I then want to use khal to see the events or khal interactive, following happens:
Traceback:
Traceback (most recent call last):
File "/usr/bin/khal", line 5, in <module>
main_khal()
File "/usr/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/lib/python3.9/site-packages/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/lib/python3.9/site-packages/khal/cli.py", line 624, in at
rows = controllers.khal_list(
File "/usr/lib/python3.9/site-packages/khal/controllers.py", line 262, in khal_list
current_events = get_events_between(
File "/usr/lib/python3.9/site-packages/khal/controllers.py", line 198, in get_events_between
event_string = event.format(agenda_format, relative_to=(start, end), env=env)
File "/usr/lib/python3.9/site-packages/khal/khalendar/event.py", line 623, in format
attributes['status'] = self.status + ' ' if self.status else ''
TypeError: can only concatenate list (not "str") to list
Debugging
Tried to debugg the issue. Looks like event.py can't handle a list of "STATUS". Tried adding a print on line 662 of event.py to print out the state:
Normal invitationICS:
~ khal at 2021-01-12 09:00
CONFIRMED
CONFIRMED
CONFIRMED
2021-01-12 09:00
09:00-10:30 meeting for this and taht
Invitation which isn't recurring for one day:
~ khal at 2021-01-11 13:00
[vText('b'CONFIRMED''), vText('b'CONFIRMED'')]
[vText('b'CONFIRMED''), vText('b'CONFIRMED'')]
[vText('b'CONFIRMED''), vText('b'CONFIRMED'')]
2021-01-11 13:00
13:00-15:00 Training ⟳
Quickfix
My quickfix for now was to add following lines inside event.py on line 661
@property
def status(self):
status=self._vevents[self.ref].get('STATUS', '')
if type(status) == list:
return status[0]
else:
return status
This just returns only the first item of a status if it's a list. But I guess it could be done better by writing a sanitize function somewhere else.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in event.py around the status property and reproduce the failure with an ICS file containing multiple STATUS fields. Determine how repeated STATUS values should be represented, then verify that khal can display the event without the reported TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100