Skip to content

[BUG] [tw_caldav_sync] iCalendar package throw exception for tasks with no priority and fails to sync #151

@karsai5

Description

@karsai5

Describe the bug

Syncing with caldav throws an error because the icalendar package throws an error converting tasks with no priority.

end of logs:

  File "/Users/user/Library/Python/3.9/lib/python/site-packages/caldav/lib/vcal.py", line 116, in create_ical
    component.add(prop, props[prop])
    │         │   │     │     └ 'priority'
    │         │   │     └ {'summary': 'test no priority', 'priority': '', 'description': '', 'status': 'NEEDS-ACTION', 'due': None, 'categories': None,...
    │         │   └ 'priority'
    │         └ <function Component.add at 0x103dbeb80>
    └ VTODO({'DTSTAMP': vDDDTypes(2025-05-23 11:27:26.165897+00:00, Parameters({})), 'UID': vText('b'159ae562-3775-11f0-bbc4-fe1681...
  File "/Users/user/Library/Python/3.9/lib/python/site-packages/icalendar/cal.py", line 192, in add
    value = self._encode(name, value, parameters, encode)
            │    │       │     │      │           └ 1
            │    │       │     │      └ None
            │    │       │     └ ''
            │    │       └ 'priority'
            │    └ <staticmethod object at 0x103d870a0>
            └ VTODO({'DTSTAMP': vDDDTypes(2025-05-23 11:27:26.165897+00:00, Parameters({})), 'UID': vText('b'159ae562-3775-11f0-bbc4-fe1681...
  File "/Users/user/Library/Python/3.9/lib/python/site-packages/icalendar/cal.py", line 143, in _encode
    obj = klass(value)
          │     └ ''
          └ <class 'icalendar.prop.vInt'>
  File "/Users/user/Library/Python/3.9/lib/python/site-packages/icalendar/prop.py", line 219, in __new__
    self = super().__new__(cls, *args, **kwargs)
                           │     │       └ {}
                           │     └ ('',)
                           └ <class 'icalendar.prop.vInt'>

ValueError: invalid literal for int() with base 10: ''

To Reproduce

Brand new install on OSX using pip3.

Sync with Baikal or Nextcloud

Expected Behavior

Sync tasks regardless of if they have priority or not

📸 Screenshots

If applicable, add screenshots to help explain your problem.

Versions

OS Version (cat /etc/*-release; uname -a)

OSX
Darwin LM-WWGL4LK7T3 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:33:47 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6030 arm64

Python version (python --version; python3 --version)

Python 3.13.3
Python 3.9.6

--version of your executable

E.g., with tw_gcal_sync, provide the output of tw_gcal_sync --version:

tw_caldav_sync, version 1.8.8

Additional context

It seems that removing this else statement to not add any priority property fixes the issue. But I'm not sure if that causes any downstream issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions