python-caldav / caldav

Apache License 2.0
314 stars 94 forks source link

URL Error is reported, but everything works fine #302

Closed pappou99 closed 1 year ago

pappou99 commented 1 year ago

While connecting to a CalDav-server python reports an error:

Possibly the server has a path handling problem, possibly the URL configured is wrong.
Path expected: /XYZ/dav//45, path found: ['/XYZ/dav/45'] Please raise an issue at https://github.com/python-caldav/caldav/issues or reach out to t-caldav@tobixen.no, include this error and the traceback and tell what server you are using.
Continuing, probably everything will be fine
tobixen commented 1 year ago

Huh! But at least it should be easy to fix some workaround for this problem. What server are you using?

tobixen commented 1 year ago

Also, what version of python-caldav are you using? As I read the current code this should not happen. The relevant code block was added 2022-09-03, and was included in release v0.10.0. Edit: the error message is indeed from that code block. Sorry, didn't sleep tonight ...

Anyway, I'll try to fix some code that simply removes the double slash.

tobixen commented 1 year ago

The branch workaround_302 should remove the error message. But it's a silly workaround, I'd like to do more research on this issue and find out when the double slash is introduced in the first place. Is it by any chance possible to create a test account on your server that I can utilize? Or do you have capacity to recheck with a version of the caldav library sprinkled with lots of asserts?

gravityfargo commented 1 year ago

I think I have an issue relating to this. When creating a todo, I get this:

Traceback (most recent call last):
  File "/home/nathan/Development/DavTasks/src/syncWorkers.py", line 55, in run
    self.createTodo(self.value1, self.value2)
  File "/home/nathan/Development/DavTasks/src/syncWorkers.py", line 342, in createTodo
    calendar.save_todo(
  File "/usr/lib/python3.10/site-packages/caldav-0.11.0-py3.10.egg/caldav/objects.py", line 730, in save_todo
    t.save(no_overwrite=no_overwrite, no_create=no_create, obj_type="todo")
  File "/usr/lib/python3.10/site-packages/caldav-0.11.0-py3.10.egg/caldav/objects.py", line 2121, in save
    self._create(id=self.id, path=path)
  File "/usr/lib/python3.10/site-packages/caldav-0.11.0-py3.10.egg/caldav/objects.py", line 1992, in _create
    self._find_id_path(id=id, path=path)
  File "/usr/lib/python3.10/site-packages/caldav-0.11.0-py3.10.egg/caldav/objects.py", line 1966, in _find_id_path
    path = self.generate_url()
  File "/usr/lib/python3.10/site-packages/caldav-0.11.0-py3.10.egg/caldav/objects.py", line 2001, in generate_url
    return self.parent.url.join(quote(self.id.replace("/", "%2F")) + ".ics")
AttributeError: 'list' object has no attribute 'replace'

This is the UID I used 9b879352-cbff-11ed-bf8c-50c2e8eec295 Specifically uidNew = uuid.uuid1().__str__() is the variable passed. and the only other thing specified was summary, which was a 1 word string.

If I do not include a UID when creating the todo, the error doesn't come up.

tobixen commented 1 year ago

Is this the latest release or the master branch? I vaguely remember I put in a bugfix for some issue like that a while ago

tobixen commented 1 year ago

Nope, it seems like I have no outstanding unreleased bugfixes. Are you using the latest version of the caldav library? Do you do something roughly like calendar.save_todo(summary='my task', uid='unique-id') ?

tobixen commented 1 year ago

At least I can see that I have this in my test suite:

        some_todo = c.save_todo(
            dtstart=datetime(2022, 12, 26, 19, 15, tzinfo=utc),
            due=datetime(2022, 12, 26, 20, 00, tzinfo=utc),
            summary="Some task",
            uid="ctuid1",
        )
gravityfargo commented 1 year ago

Oof, I was an update or so behind. Please disregard this; thanks for the fast reply! :smile: