dav: Help debugging a calendar query error
Hi,
I’ve been working with HomeAssistant (Core 2020.12.1 installed on a recent Gentoo server) in connecting to a Baïkal calendar and have been tracing an odd issue. In debugging I’m seeing that the query is handled by sabre-io/dav and then passed to sabre-io/vobject, but I believe sabre-io/dav is the correct place to discuss this issue. See below for further details.
I’ve connected successfully to the test calendar using AgenDav and Moz Thunderbird, so everything appears to be working well with Baïkal (v0.7.2). When HomeAssistant attempts to connect to the server, it sends several successful request (PROPFINDs with 207 results), but eventually uses python’s caldav package (v0.6.1) to create the following calendar query to the Baïkal server.
<?xml version='1.0' encoding='utf-8'?>
<C:calendar-query xmlns:D="DAV" xmlns:C="urn:ietf:params:xml:ns:caldav" xmlns:I="http://apple.com/ns/ical/">
<ns0:prop xmlns:ns0="DAV:">
<C:calendar-data>
<C:expand start="20210108T080000Z" end="20210115T080000Z"/>
</C:calendar-data>
</ns0:prop>
<C:filter>
<C:comp-filter name="VCALENDAR">
<C:comp-filter name="VEVENT">
<C:time-range start="20210108T080000Z" end="20210115T080000Z"/>
</C:comp-filter>
</C:comp-filter>
</C:filter>
</C:calendar-query>
This query is received by the Baïkal instance running on apache (on the same host) and apache unfortunately returns a 500 error:
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<s:sabredav-version>4.1.2</s:sabredav-version>
<s:exception>Sabre\\VObject\\ParseException</s:exception>
<s:message>This parser only supports VCARD and VCALENDAR files</s:message>
</d:error>
I put a print statement in saber/vobject’s MimeDir.php file at the above error output and a timezone string is output, so I changed the timezone setting on the Baïkal calendar being queried and that change was reflected in the debugging output. I put a stack trace into that point in the code (baikal/vendor/sabre/vobject/lib/Parser/MimeDir.php after the default in the switch statement) and got this:
#1 Sabre\VObject\Parser\MimeDir->parse(America/Indiana/Tell_City, 0) called at [<wwwroot>/baikal/vendor/sabre/vobject/lib/Reader.php:47]
#2 Sabre\VObject\Reader::read(America/Indiana/Tell_City) called at [<wwwroot>/baikal/vendor/sabre/dav/lib/CalDAV/Plugin.php:513]
#3 Sabre\CalDAV\Plugin->calendarQueryReport(Sabre\CalDAV\Xml\Request\CalendarQueryReport Object ([properties] => Array ([0] => {urn:ietf:params:xml:ns:caldav}calendar-data),[filters] => Array ([name] => VCALENDAR,[is-not\
-defined] => ,[comp-filters] => Array ([0] => Array ([name] => VEVENT,[is-not-defined] => ,[comp-filters] => Array (),[prop-filters] => Array (),[time-range] => Array ([start] => DateTimeImmutable Object (),[end] => DateT\
imeImmutable Object ()))),[prop-filters] => Array (),[time-range] => ),[expand] => Array ([start] => DateTimeImmutable Object (),[end] => DateTimeImmutable Object ()),[contentType] => text/calendar,[version] => 2.0)) call\
ed at [<wwwroot>/baikal/vendor/sabre/dav/lib/CalDAV/Plugin.php:258]
#4 Sabre\CalDAV\Plugin->report({urn:ietf:params:xml:ns:caldav}calendar-query, Sabre\CalDAV\Xml\Request\CalendarQueryReport Object ([properties] => Array ([0] => {urn:ietf:params:xml:ns:caldav}calendar-data),[filters] => \
Array ([name] => VCALENDAR,[is-not-defined] => ,[comp-filters] => Array ([0] => Array ([name] => VEVENT,[is-not-defined] => ,[comp-filters] => Array (),[prop-filters] => Array (),[time-range] => Array ([start] => DateTime\
Immutable Object (),[end] => DateTimeImmutable Object ()))),[prop-filters] => Array (),[time-range] => ),[expand] => Array ([start] => DateTimeImmutable Object (),[end] => DateTimeImmutable Object ()),[contentType] => tex\
t/calendar,[version] => 2.0), calendars/home/testing) called at [<wwwroot>/baikal/vendor/sabre/event/lib/WildcardEmitterTrait.php:89]
#5 Sabre\DAV\Server->emit(report, Array ([0] => {urn:ietf:params:xml:ns:caldav}calendar-query,[1] => Sabre\CalDAV\Xml\Request\CalendarQueryReport Object ([properties] => Array ([0] => {urn:ietf:params:xml:ns:caldav}calen\
dar-data),[filters] => Array ([name] => VCALENDAR,[is-not-defined] => ,[comp-filters] => Array ([0] => Array ([name] => VEVENT,[is-not-defined] => ,[comp-filters] => Array (),[prop-filters] => Array (),[time-range] => Arr\
ay ([start] => DateTimeImmutable Object (),[end] => DateTimeImmutable Object ()))),[prop-filters] => Array (),[time-range] => ),[expand] => Array ([start] => DateTimeImmutable Object (),[end] => DateTimeImmutable Object (\
)),[contentType] => text/calendar,[version] => 2.0),[2] => calendars/home/testing)) called at [<wwwroot>/baikal/vendor/sabre/dav/lib/DAV/CorePlugin.php:685]
#6 Sabre\DAV\CorePlugin->httpReport(Sabre\HTTP\Request Object ([^@*^@method] => REPORT,[^@*^@url] => /baikal/dav.php/calendars/home/testing/,[^@*^@absoluteUrl] => http://cal/baikal/dav.php/calendars/home/testing/,[^@*^@b\
aseUrl] => /baikal/dav.php/,[^@*^@postData] => Array (),[^@*^@rawServerData] => Array ([UNIQUE_ID] => X-k-5O4sPUXmMSPmuTrhzwAAAFA,[SCRIPT_URL] => /baikal/dav.php/calendars/home/testing/,[SCRIPT_URI] => http://cal/baikal/d\
av.php/calendars/home/testing/,[HTTP_HOST] => cal,[HTTP_USER_AGENT] => Mozilla/5.0,[HTTP_ACCEPT_ENCODING] => gzip, deflate,[HTTP_ACCEPT] => text/xml, text/calendar,[HTTP_CONNECTION] => keep-alive,[CONTENT_TYPE] => applica\
tion/xml; charset="utf-8",[HTTP_DEPTH] => 1,[CONTENT_LENGTH] => 475,[PATH] => /bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin,[SERVER_SIGNATURE] => <address>Apache Serve\
r at cal Port 80</address>
,[SERVER_SOFTWARE] => Apache,[SERVER_NAME] => cal,[SERVER_ADDR] => <ServerIP>,[SERVER_PORT] => 80,[REMOTE_ADDR] => <ServerIP>,[DOCUMENT_ROOT] => <wwwroot>/,[REQUEST_SCHEME] => http,[CONTEXT_PREFIX] => ,[CONTEXT_DOCUMENT_R\
OOT] => <wwwroot>/,[SERVER_ADMIN] => [no address given],[SCRIPT_FILENAME] => <wwwroot>/baikal/dav.php,[REMOTE_PORT] => 38136,[GATEWAY_INTERFACE] => CGI/1.1,[SERVER_PROTOCOL] => HTTP/1.1,[REQUEST_METHOD] => REPORT,[QUERY_S\
TRING] => ,[REQUEST_URI] => /baikal/dav.php/calendars/home/testing/,[SCRIPT_NAME] => /baikal/dav.php,[PATH_INFO] => /calendars/home/testing/,[PATH_TRANSLATED] => <wwwroot>/calendars/home/testing/,[PHP_SELF] => /baikal/dav\
.php/calendars/home/testing/,[PHP_AUTH_DIGEST] => username="home", realm="BaikalDAV", nonce="5ff93fe4b75d6", uri="/baikal/dav.php/calendars/home/testing/", response="fae04a2d75f9a1af6751d8a14363c256", opaque="d66d5f052403\
6afcb61420e358f990ce", qop="auth", nc=00000004, cnonce="6ba2928b623a1bae",[REQUEST_TIME_FLOAT] => 1610170340.8157,[REQUEST_TIME] => 1610170340),[^@*^@body] => Resource id #10,[^@*^@headers] => Array ([host] => Array ([0] \
=> Host,[1] => Array ([0] => cal)),[user-agent] => Array ([0] => User-Agent,[1] => Array ([0] => Mozilla/5.0)),[accept-encoding] => Array ([0] => Accept-Encoding,[1] => Array ([0] => gzip, deflate)),[accept] => Array ([0]\
=> Accept,[1] => Array ([0] => text/xml, text/calendar)),[connection] => Array ([0] => Connection,[1] => Array ([0] => keep-alive)),[content-type] => Array ([0] => Content-Type,[1] => Array ([0] => application/xml; chars\
et="utf-8")),[depth] => Array ([0] => Depth,[1] => Array ([0] => 1)),[content-length] => Array ([0] => Content-Length,[1] => Array ([0] => 475)),[authorization] => Array ([0] => Authorization,[1] => Array ([0] => Digest u\
sername="home", realm="BaikalDAV", nonce="5ff93fe4b75d6", uri="/baikal/dav.php/calendars/home/testing/", response="fae04a2d75f9a1af6751d8a14363c256", opaque="d66d5f0524036afcb61420e358f990ce", qop="auth", nc=00000004, cno\
nce="6ba2928b623a1bae"))),[^@*^@httpVersion] => 1.1), Sabre\HTTP\Response Object ([^@*^@status] => 500,[^@*^@statusText] => Internal Server Error,[^@*^@body] => ,[^@*^@headers] => Array ([x-sabre-version] => Array ([0] =>\
X-Sabre-Version,[1] => Array ([0] => 4.1.2))),[^@*^@httpVersion] => 1.1)) called at [<wwwroot>/baikal/vendor/sabre/event/lib/WildcardEmitterTrait.php:89]
#7 Sabre\DAV\Server->emit(method:REPORT, Array ([0] => Sabre\HTTP\Request Object ([^@*^@method] => REPORT,[^@*^@url] => /baikal/dav.php/calendars/home/testing/,[^@*^@absoluteUrl] => http://cal/baikal/dav.php/calendars/ho\
me/testing/,[^@*^@baseUrl] => /baikal/dav.php/,[^@*^@postData] => Array (),[^@*^@rawServerData] => Array ([UNIQUE_ID] => X-k-5O4sPUXmMSPmuTrhzwAAAFA,[SCRIPT_URL] => /baikal/dav.php/calendars/home/testing/,[SCRIPT_URI] => \
http://cal/baikal/dav.php/calendars/home/testing/,[HTTP_HOST] => cal,[HTTP_USER_AGENT] => Mozilla/5.0,[HTTP_ACCEPT_ENCODING] => gzip, deflate,[HTTP_ACCEPT] => text/xml, text/calendar,[HTTP_CONNECTION] => keep-alive,[CONTE\
NT_TYPE] => application/xml; charset="utf-8",[HTTP_DEPTH] => 1,[CONTENT_LENGTH] => 475,[PATH] => /bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin,[SERVER_SIGNATURE] => <a\
ddress>Apache Server at cal Port 80</address>
,[SERVER_SOFTWARE] => Apache,[SERVER_NAME] => cal,[SERVER_ADDR] => <ServerIP>,[SERVER_PORT] => 80,[REMOTE_ADDR] => <ServerIP>,[DOCUMENT_ROOT] => <wwwroot>/,[REQUEST_SCHEME] => http,[CONTEXT_PREFIX] => ,[CONTEXT_DOCUMENT_R\
OOT] => <wwwroot>/,[SERVER_ADMIN] => [no address given],[SCRIPT_FILENAME] => <wwwroot>/baikal/dav.php,[REMOTE_PORT] => 38136,[GATEWAY_INTERFACE] => CGI/1.1,[SERVER_PROTOCOL] => HTTP/1.1,[REQUEST_METHOD] => REPORT,[QUERY_S\
TRING] => ,[REQUEST_URI] => /baikal/dav.php/calendars/home/testing/,[SCRIPT_NAME] => /baikal/dav.php,[PATH_INFO] => /calendars/home/testing/,[PATH_TRANSLATED] => <wwwroot>/calendars/home/testing/,[PHP_SELF] => /baikal/dav\
.php/calendars/home/testing/,[PHP_AUTH_DIGEST] => username="home", realm="BaikalDAV", nonce="5ff93fe4b75d6", uri="/baikal/dav.php/calendars/home/testing/", response="fae04a2d75f9a1af6751d8a14363c256", opaque="d66d5f052403\
6afcb61420e358f990ce", qop="auth", nc=00000004, cnonce="6ba2928b623a1bae",[REQUEST_TIME_FLOAT] => 1610170340.8157,[REQUEST_TIME] => 1610170340),[^@*^@body] => Resource id #10,[^@*^@headers] => Array ([host] => Array ([0] \
=> Host,[1] => Array ([0] => cal)),[user-agent] => Array ([0] => User-Agent,[1] => Array ([0] => Mozilla/5.0)),[accept-encoding] => Array ([0] => Accept-Encoding,[1] => Array ([0] => gzip, deflate)),[accept] => Array ([0]\
=> Accept,[1] => Array ([0] => text/xml, text/calendar)),[connection] => Array ([0] => Connection,[1] => Array ([0] => keep-alive)),[content-type] => Array ([0] => Content-Type,[1] => Array ([0] => application/xml; chars\
et="utf-8")),[depth] => Array ([0] => Depth,[1] => Array ([0] => 1)),[content-length] => Array ([0] => Content-Length,[1] => Array ([0] => 475)),[authorization] => Array ([0] => Authorization,[1] => Array ([0] => Digest u\
sername="home", realm="BaikalDAV", nonce="5ff93fe4b75d6", uri="/baikal/dav.php/calendars/home/testing/", response="fae04a2d75f9a1af6751d8a14363c256", opaque="d66d5f0524036afcb61420e358f990ce", qop="auth", nc=00000004, cno\
nce="6ba2928b623a1bae"))),[^@*^@httpVersion] => 1.1),[1] => Sabre\HTTP\Response Object ([^@*^@status] => 500,[^@*^@statusText] => Internal Server Error,[^@*^@body] => ,[^@*^@headers] => Array ([x-sabre-version] => Array (\
[0] => X-Sabre-Version,[1] => Array ([0] => 4.1.2))),[^@*^@httpVersion] => 1.1))) called at [<wwwroot>/baikal/vendor/sabre/dav/lib/DAV/Server.php:472]
#8 Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request Object ([^@*^@method] => REPORT,[^@*^@url] => /baikal/dav.php/calendars/home/testing/,[^@*^@absoluteUrl] => http://cal/baikal/dav.php/calendars/home/testing/,[^@*^@bas\
eUrl] => /baikal/dav.php/,[^@*^@postData] => Array (),[^@*^@rawServerData] => Array ([UNIQUE_ID] => X-k-5O4sPUXmMSPmuTrhzwAAAFA,[SCRIPT_URL] => /baikal/dav.php/calendars/home/testing/,[SCRIPT_URI] => http://cal/baikal/dav\
.php/calendars/home/testing/,[HTTP_HOST] => cal,[HTTP_USER_AGENT] => Mozilla/5.0,[HTTP_ACCEPT_ENCODING] => gzip, deflate,[HTTP_ACCEPT] => text/xml, text/calendar,[HTTP_CONNECTION] => keep-alive,[CONTENT_TYPE] => applicati\
on/xml; charset="utf-8",[HTTP_DEPTH] => 1,[CONTENT_LENGTH] => 475,[PATH] => /bin:/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/bin,[SERVER_SIGNATURE] => <address>Apache Server \
at cal Port 80</address> ,[SERVER_SOFTWARE] => Apache,[SERVER_NAME] => cal,[SERVER_ADDR] => <ServerIP>,[SERVER_PORT] => 80,[REMOTE_ADDR] => <ServerIP>,[DOCUMENT_ROOT] => <wwwroot>/,[REQUEST_SCHEME] => http,[CONTEXT_PREFIX] => ,[CONTEXT_DOCUMENT_R\
OOT] => <wwwroot>/,[SERVER_ADMIN] => [no address given],[SCRIPT_FILENAME] => <wwwroot>/baikal/dav.php,[REMOTE_PORT] => 38136,[GATEWAY_INTERFACE] => CGI/1.1,[SERVER_PROTOCOL] => HTTP/1.1,[REQUEST_METHOD] => REPORT,[QUERY_S\
TRING] => ,[REQUEST_URI] => /baikal/dav.php/calendars/home/testing/,[SCRIPT_NAME] => /baikal/dav.php,[PATH_INFO] => /calendars/home/testing/,[PATH_TRANSLATED] => <wwwroot>/calendars/home/testing/,[PHP_SELF] => /baikal/dav\
.php/calendars/home/testing/,[PHP_AUTH_DIGEST] => username="home", realm="BaikalDAV", nonce="5ff93fe4b75d6", uri="/baikal/dav.php/calendars/home/testing/", response="fae04a2d75f9a1af6751d8a14363c256", opaque="d66d5f052403\
6afcb61420e358f990ce", qop="auth", nc=00000004, cnonce="6ba2928b623a1bae",[REQUEST_TIME_FLOAT] => 1610170340.8157,[REQUEST_TIME] => 1610170340),[^@*^@body] => Resource id #10,[^@*^@headers] => Array ([host] => Array ([0] \
=> Host,[1] => Array ([0] => cal)),[user-agent] => Array ([0] => User-Agent,[1] => Array ([0] => Mozilla/5.0)),[accept-encoding] => Array ([0] => Accept-Encoding,[1] => Array ([0] => gzip, deflate)),[accept] => Array ([0]\
=> Accept,[1] => Array ([0] => text/xml, text/calendar)),[connection] => Array ([0] => Connection,[1] => Array ([0] => keep-alive)),[content-type] => Array ([0] => Content-Type,[1] => Array ([0] => application/xml; chars\
et="utf-8")),[depth] => Array ([0] => Depth,[1] => Array ([0] => 1)),[content-length] => Array ([0] => Content-Length,[1] => Array ([0] => 475)),[authorization] => Array ([0] => Authorization,[1] => Array ([0] => Digest u\
sername="home", realm="BaikalDAV", nonce="5ff93fe4b75d6", uri="/baikal/dav.php/calendars/home/testing/", response="fae04a2d75f9a1af6751d8a14363c256", opaque="d66d5f0524036afcb61420e358f990ce", qop="auth", nc=00000004, cno\
nce="6ba2928b623a1bae"))),[^@*^@httpVersion] => 1.1), Sabre\HTTP\Response Object ([^@*^@status] => 500,[^@*^@statusText] => Internal Server Error,[^@*^@body] => ,[^@*^@headers] => Array ([x-sabre-version] => Array ([0] =>\
X-Sabre-Version,[1] => Array ([0] => 4.1.2))),[^@*^@httpVersion] => 1.1)) called at [<wwwroot>/baikal/vendor/sabre/dav/lib/DAV/Server.php:253]
#9 Sabre\DAV\Server->start() called at [<wwwroot>/baikal/vendor/sabre/dav/lib/DAV/Server.php:321]
#10 Sabre\DAV\Server->exec() called at [<wwwroot>/baikal/Core/Frameworks/Baikal/Core/Server.php:119]
#11 Baikal\Core\Server->start() called at [<wwwroot>/baikal/dav.php:69]
I’m not a rfc4791 expert, just a guy trying to get a shared calendar resource setup on his home server for use in some home automation. If anyone can look over the calendar-query or the backtrace to ensure it’s valid or other acceptable caldav requests, please let me know.
Any suggestions on how to further debug this would be appreciated.
Thanks! Elliott
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 21 (1 by maintainers)
Commits related to this issue
- bugfix for TimeZone issue https://github.com/sabre-io/dav/issues/1318 — committed to gador/docker-baikal-infcloud by gador 3 years ago
- fix: https://github.com/sabre-io/dav/issues/1318 — committed to MrAlucardDante/baikal-docker-hass by MrAlucardDante 9 months ago
- fix: https://github.com/sabre-io/dav/issues/1318 — committed to MrAlucardDante/baikal-docker-hass by MrAlucardDante 9 months ago
Looking closer at CalDAV\Plugin.php:513, I can see the call to VObject\Reader::read($tzResult[$tzProp]), which is where the timezone is being passed to vobject’s parser. Apparently this has been discussed before https://github.com/sabre-io/Baikal/issues/695#issuecomment-394112977 and the following was suggested by @evert https://github.com/sabre-io/Baikal/issues/695#issuecomment-487299181
I have been able to get things to work if I perform the following modification to CalDAV\Plugin.php:
I don’t know what kind of effect doing so will have on other systems, but this change is working for me now. I’ll do some more testing and report back if I have any further issues.
If you use the docker image from ckulka, I have created a docker image that’s based on his nginx variant (I don’t use the apache/httpd variant, but since it’s just the webserver, migrating should work out of the box) which includes this fix.
Here is the image name and tag : ghcr.io/mralucarddante/baikal-docker-hass:0.9.4-msmtp
And the code is on GitHub if you want to make sure I don’t do anything shady in the Dockerfile (of course I don’t) https://github.com/MrAlucardDante/baikal-docker-hass
Hi, the patch https://github.com/sabre-io/dav/issues/1318#issuecomment-757380175 worked for me. the file in the docker container can be copied to a local and back after the patch:
docker cp baikal:/var/www/baikal/vendor/sabre/dav/lib/CalDAV/Plugin.php .Is there any chance this will get fixed? I’m trying to connect my baikal calendars to Home Assistant and believe I have run into this issue