python-caldav / caldav

Apache License 2.0
319 stars 94 forks source link

Errors connecting to Synology Calendar server #191

Closed RichJeanes closed 2 years ago

RichJeanes commented 2 years ago

I am running Synology Calendar 2.4.5-10930 and Home Assistant 2022.6.0. When attempting to connect my calendar, Home Assistant doesn't load any calendars and the following errors appear in the logs. The server URL in the configuration is https://<server>/caldav/<user@ldap>.

2022-06-05 12:34:59 ERROR (SyncWorker_6) [caldav] Possibly the server has a path handling problem. Path expected: /caldav/<user@ldap>, path found: ['/caldav.php/<user@ldap>/'] 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

2022-06-05 12:34:59 ERROR (SyncWorker_6) [caldav] Deviation from expectations found. 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
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/caldav/lib/error.py", line 25, in assert_
assert(condition)
AssertionError

2022-06-05 12:35:08 ERROR (MainThread) [homeassistant.components.calendar] Error while setting up caldav platform for calendar
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
await asyncio.shield(task)
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/caldav/calendar.py", line 87, in setup_platform
calendars = client.principal().calendars()
File "/usr/local/lib/python3.9/site-packages/caldav/davclient.py", line 356, in principal
self._principal = Principal(client=self, *largs, **kwargs)
File "/usr/local/lib/python3.9/site-packages/caldav/objects.py", line 403, in __init__
cup = self.get_property(dav.CurrentUserPrincipal())
File "/usr/local/lib/python3.9/site-packages/caldav/objects.py", line 174, in get_property
foo = self.get_properties([prop], **passthrough)
File "/usr/local/lib/python3.9/site-packages/caldav/objects.py", line 244, in get_properties
self.props.update(rc)
TypeError: 'NoneType' object is not iterable

Usernames and server names have been redacted to "\<name>". The configuration does not include any "<" or ">" symbols.

tobixen commented 2 years ago

Is there any possibility to set up a testing account on the Synology server that I could use for running the test code, pinpointing the problem and test a bugfix or workaround?

tobixen commented 2 years ago

Gotcha! (sorry for spending so long time before looking properly into this).

Synology suggests to use the URL path /caldav/username@ldap.example.com

The first thing I did was to shorten it down to just /caldav/

However, that also didn't solve the problem. I went in with the debugger, and found that the URL reported back from the server is /caldav.php/ !

Changing the URL in the config to end with /caldav.php seems to resolve the traceback above.

This is an issue at the server side .... but the error handling on the client side is also rather lacking.

My philosophy has all the time been that the library should work around slightly wrong configuration as well as common server compatibility issues, so I will conside rsome workaround in the client library.

tobixen commented 2 years ago

(and also, when changing the config above, I ran into 405 errors from the server. I hope to get more time to look into it today)

tobixen commented 2 years ago

Latest version of master should work with your Synology.

Except for the .php-issue, it seems to be a good server, quite few incompatibility issues found (one minor failure in the sync token test, but that's not a breach of the RFC and won't cause problems. Some problems when doing date search for tasks (VTODO), but almost all server implementations fail that test).