pimutils / pimutils/khal

ikhal crashes when creating new event with filtered calendars

Open
#1,380 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.1k
Forks
233
Avg merge
1h 44m
Merged PRs (30d)
1

Description

Describe the bug
When opening ikhal with the -a-argument set to something other than the default it crashes when trying to create a new calendar entry.

If applicable: Stack Trace

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/khal/ui/__init__.py", line 1363, in start_pane
    loop.run()
  File "/usr/lib/python3.12/site-packages/urwid/event_loop/main_loop.py", line 337, in run
    self._run()
  File "/usr/lib/python3.12/site-packages/urwid/event_loop/main_loop.py", line 439, in _run
    self.event_loop.run()
  File "/usr/lib/python3.12/site-packages/urwid/event_loop/select_loop.py", line 182, in run
    self._loop()
  File "/usr/lib/python3.12/site-packages/urwid/event_loop/select_loop.py", line 229, in _loop
    record.data()
  File "/usr/lib/python3.12/site-packages/urwid/display/_posix_raw_display.py", line 273, in wrapper
    return self.parse_input(event_loop, callback, self.get_available_raw_input())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/urwid/display/_raw_display_base.py", line 488, in parse_input
    callback(decoded_codes, raw_codes)
  File "/usr/lib/python3.12/site-packages/urwid/event_loop/main_loop.py", line 466, in _update
    self.process_input(keys)
  File "/usr/lib/python3.12/site-packages/urwid/event_loop/main_loop.py", line 566, in process_input
    handled_key = self._topmost_widget.keypress(self.screen_size, key)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/urwid/widget/popup.py", line 143, in keypress
    return self._current_widget.keypress(size, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/urwid/widget/frame.py", line 526, in keypress
    return self.body.keypress((maxcol, remaining), key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/khal/ui/__init__.py", line 1123, in keypress
    return super().keypress(size, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/khal/ui/base.py", line 114, in keypress
    return super().keypress(size, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/urwid/widget/widget.py", line 729, in keypress
    return get_delegate(self).keypress(size, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/khal/ui/widgets.py", line 313, in keypress
    key = super().keypress(size, key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/urwid/widget/columns.py", line 1216, in keypress
    key = w.keypress(size_args[i], key)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/urwid/widget/widget.py", line 729, in keypress
    return get_delegate(self).keypress(size, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/urwid/widget/widget.py", line 729, in keypress
    return get_delegate(self).keypress(size, key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/urwid/widget/frame.py", line 526, in keypress
    return self.body.keypress((maxcol, remaining), key)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/khal/ui/calendarwidget.py", line 330, in keypress
    return self.on_press[key](start, end)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/khal/ui/__init__.py", line 1177, in new_event
    self.eventscolumn.original_widget.new(date, end)
  File "/usr/lib/python3.12/site-packages/khal/ui/__init__.py", line 895, in new
    self.edit(event)
  File "/usr/lib/python3.12/site-packages/khal/ui/__init__.py", line 762, in edit
    editor = EventEditor(self.pane, event, update_colors, always_save=always_save)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/khal/ui/editor.py", line 374, in __init__
    self.collection._calendars[self.event.calendar],
    ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
KeyError: 'personal'

(Note: personal is my configured default, and is not included in the calendars to display)

To Reproduce
Steps to reproduce the behavior:

  • Configure khal with multiple calendars
  • Set one (cal1) as the default
  • Open ikhal filtering for another one: ikhal -a cal2
  • Try to create a new date

Expected behavior
I can create a new appointment, with either cal2 or no calendar selected (In case of multiple calendars being included" any of them/none of them)

OS, version, khal version and how you installed it:

  • The output of khal --version: khal, version 0.11.3
  • Installation method: Archlinux Repo
  • python version: 3.12.7
  • OS: Archlinux
  • Your khal config file:
[calendars]
    [[personal]]
        path = ~/.local/share/vdirsyncer/calendar/personal
    [[voltstock]]
        path = ~/.local/share/vdirsyncer/ws_calendar/voltstock-infos-1/
  (<Stripped: Some more calendars>)

[locale]
    weeknumbers = left
    unicode_symbols = False
    longdateformat = %Y-%m-%d
    longdatetimeformat = %Y-%m-%d %H:%M
    datetimeformat = %m-%d %H:%M
    dateformat = %m-%d
    firstweekday = 0

[default]
    default_calendar = personal
    timedelta = 3d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in khal/ui/editor.py at EventEditor.init, then trace the new-event path through khal/ui/init.py and reproduce with ikhal -a cal2. Verify that creating an event with a filtered calendar no longer raises the reported KeyError and allows the expected calendar selection or no calendar.

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
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.