home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.16k stars 29.84k forks source link

500 Internal Server Error in CalDAV extension with Baikal #111421

Closed update-freak closed 2 months ago

update-freak commented 6 months ago

The problem

I have the problem that with the CalDAV extension (https://www.home-assistant.io/integrations/caldav/) I got the error "500 Internal Server Error" in the log (see attached file). In the overview I got the items of the To-Do-list, but the entries from the calanders are emtpy.

HA_log.txt

What version of Home Assistant Core has the issue?

core-2024.2.3

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

CalDAV

Link to integration documentation on our website

https://www.home-assistant.io/integrations/caldav/

Diagnostics information

home-assistant_caldav_2024-02-25T21-13-08.720Z.log

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

Baikal is installed as docker container on a Synology NAS. Home Assistant is installed as VM on a Synology NAS. The Reverse Proxy is used to create a URL like this: https://baikal.example.dynv6.net

home-assistant[bot] commented 6 months ago

caldav documentation caldav source

TheZoker commented 6 months ago

Same issue here. ToDo seems to work, but calendars are not synced as expected with the same error message

update-freak commented 6 months ago

I guess this error is also related to https://github.com/sabre-io/Baikal/issues/1241

tobixen commented 6 months ago

This may be a compatibility issue between the python-caldav library and the baikal server. If you are willing to create a test account for me or share some username/password with me (privately) I may try to look a bit into it.

TheZoker commented 6 months ago

@tobixen I can provide you an dev setup if that helps (without any data on it). Would that help? If yes, please let me know, where I can reach you

tobixen commented 6 months ago

Yes, as long as the dev setup has the same problems, then it's useful. You can use t-caldav-111421@tobixen.no

tobixen commented 6 months ago

I ran the python-caldav test suite towards the baikal server provided, and I'm sorry to say ... that all tests passed. This either means the problem is specific to the Home Assistant caldav integration or that my test code is not able to trigger the problem. (or that the problem is not present on the dev setup, but present on the Synology setup).

(That said, "500 internal server error" should usually mean that there is a problem on the server side, and there should usually be something in the server log about it).

update-freak commented 6 months ago

I tried it now again with https://baikal.example.dynv6.net/dav.php and with http://192.168.178.27:49179/dav.php

I attached the log file from baikal in portainer. Maybe this helps. error log baikal.txt

tobixen commented 6 months ago

(This comment has been updated to squash in my "train of thought" in now deleted following comments)

This is the smoking gun:

2024/03/07 06:00:32 [error] 53#53: *2781 FastCGI sent in stderr: "PHP message: Sabre\VObject\ParseException: This parser only supports VCARD and VCALENDAR files in /var/www/baikal/vendor/sabre/vobject/lib/Parser/MimeDir.php:163

My first thought is that there is something wrong with the icalendar data sent, the server does not recognize it as valid VCALENDAR. However, HomeAssistant is doing a REPORT-query to fetch icalendar data from the server, so that's not the case. Probably there is something specific in the REPORT-query that breaks baikal.

In the next release of the python-caldav library it will be possible to set an environmental variable, and it will dump all the caldav communication to files under /tmp. This will at some point in the future make it easy to extract more debug information from those of us running HomeAssistant in "supervised"-mode on a linux system. Right here and now I think the only solution is to try to get the communication out on the server side. With the http-solution it should be possible to use tcpdump. @update-freak, if you have any chance running tcpdump on 192.168.178.27, then please do. Something like this should catch the whole REPORT-request:

sudo tcpdump -w /tmp/caldav.pcap -I any port 49179
purche42 commented 6 months ago

This may be a problem which occurs on Baikal docker deployment (ckulka/baikal:nginx) . I have the same issue with "500 Internal Server Error" with HA CalDAV while Baikal is working fine with several other clients. I also got the same message : "This parser only supports VCARD and VCALENDAR files"

It looks similar to an older problem described here : https://github.com/sabre-io/dav/issues/1318#issuecomment-757380175

this is related to this bug "There is a bug in upstream Baikal with a timezone that makes Home Assistant unable to read calendars from the server. A solution was developed https://github.com/sabre-io/dav/issues/1318#issuecomment-1872627379, but has to be reapplied every time the container restarts or updates."

update-freak commented 6 months ago

Thanks a lot! Using this docker image from above (https://github.com/sabre-io/dav/issues/1318#issuecomment-1872627379) solved the issue: ghcr.io/mralucarddante/baikal-docker-hass:latest

N3RO365 commented 5 months ago

Thanks a lot! Using this docker image from above (sabre-io/dav#1318 (comment)) solved the issue: ghcr.io/mralucarddante/baikal-docker-hass:latest

Hello.

Can I simply replace the Docker url or do I have to reinstall the Docker and then set everything up again?

update-freak commented 5 months ago

I simply changed the URL and it worked out of the box. (but as always: save your data first)

issue-triage-workflows[bot] commented 2 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.